【发布时间】:2014-03-17 19:04:07
【问题描述】:
我遇到了一个错误
[__NSCFNumber 长度]:无法识别的选择器发送到实例 0x15580c90 2014-02-18 15:10:49.490 CIB[1706:60b] * 由于未捕获的异常“NSInvalidArgumentException”而终止应用程序,原因:“-[__NSCFNumber 长度]:无法识别的选择器发送到实例 0x15580c90” * 首先抛出调用栈: (0x2da18e83 0x37d756c7 0x2da1c7b7 0x2da1b0af 0x2d969dc8 0x2e33b695 0x2e33b169 0x301ab2fd 0x1603ad 0x302cf315 0x302776cd 0x30276ef1 0x3019d353 0x2fe23943 0x2fe1f167 0x2fe1eff9 0x2fe1ea0d 0x2fe1e81f 0x2fe1854d 0x2d9e3f69 0x2d9e18f7 0x2d9e1c43 0x2d94c471 0x2d94c253 0x326862eb 0x30201845 0x113de1 0x3826eab7) libc++abi.dylib:以 NSException 类型的未捕获异常终止
我这里有循环。从 Json 中的数组到我的模型任务列表,然后存储到 NSMutableArray _tasklist
NSArray *taskJson = [json objectForKey:@"fOTaskListModelWss"];
for (NSDictionary *dictCQ in taskJson) {
NSLog(@"TASKLIST: %@", [dictCQ objectForKey:@"foTaskListModelWs"]);
NSDictionary *datadic = [dictCQ objectForKey:@"foTaskListModelWs"];
TaskList *task = [[TaskList alloc]init];
[task setTaskCount:datadic[@"count"]];
[task setFuncCd:datadic[@"funcCd"]];
[task setFuncCdDscp:datadic[@"funcCdDscp"]];
[task setRequestStatus:datadic[@"requestStatus"]];
[task setRole:datadic[@"role"]];
[_taskList addObject:task];
}
那么这是我在 cellForRowAtRowPathIndex 中的代码
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
static NSString * simpleTableIdentifier = @"MenuTableViewCell";
MenuTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];
if (cell == nil) {
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"MenuTableViewCell" owner:self options:nil];
cell = [nib objectAtIndex:0];
}
TaskList *txn = [_taskList objectAtIndex:indexPath.row];
cell.titleLabel.text = txn.funcCdDscp;
cell.totalCountLabel.text = txn.taskCount;
return cell;}
【问题讨论】:
-
检查你的表格行数
-
你是否在你的表 numberofrowsection 和 cellForRowAtIndexPath 方法上放置了断点,其中发生了方法错误?
标签: ios objective-c json uitableview nsmutablearray