程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 更多編程語言 >> 編程綜合問答 >> ios-numberofRowsinSection 返回值

ios-numberofRowsinSection 返回值

編輯:編程綜合問答
numberofRowsinSection 返回值

能不能將NSMutableArray返回成數字形式。

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    NSLog(@"number of rows in section: %@",[arrayofNombre objectAtIndex:section]);//it prints the right value
    return [arrayofNombre objectAtIndex:section];
}

代碼一運行就崩潰。如果放進一個常數值,運行之後的結果也不對。求高手指點,謝謝。

最佳回答:


首先保證你的section 不會超過下標索引,不然會因超出索引而引發程序crash
如果要返回NSInteger需要作類型轉換

return [[arrayofNombre objectAtIndex:section] intValue];

但要保證你數組中的都是int類型,不然也會因為類型轉換失敗而導致程序crash.

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved