lhencq lhencq - 1 year ago 158
JSON Question

[__NSCFNumber length]: unrecognized selector sent to instance UITableView

i'm experiencing an error

[__NSCFNumber length]: unrecognized selector sent to instance 0x15580c90
2014-02-18 15:10:49.490 CIB[1706:60b] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFNumber length]: unrecognized selector sent to instance 0x15580c90'
First throw call stack:
(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: terminating with uncaught exception of type NSException

I have loop here. from array in Json to my model tasklist then stored to 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];

then here is my code in 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;}

Answer Source
cell.titleLabel.text = txn.funcCdDscp;
cell.totalCountLabel.text = txn.taskCount;

One of these (not sure which, but my guess would be taskCount) is a NSNumber. Text takes an NSString.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download