browser icon
You are using an insecure version of your web browser. Please update your browser!
Using an outdated browser makes your computer unsafe. For a safer, faster, more enjoyable user experience, please update your browser today or try a newer browser.

配列やキューからindexを指定して値を取り出すときの注意 – iPhone開発メモ

Posted by on 2013年1月28日


-[NSCFNumber length]: unrecognized selector sent to instance 0x4b54de0 * Terminating app due to uncaught exception ‘NSInvalidArgumentException’, reason: ‘-[NSCFNumber length]: unrecognized selector sent to instance 0x4b54de0′

このエラーは、配列やキューの値を取り出すときに、objectAtIndex:が NSNumber型ではなく、NSString型でreturnされている場合に発生します。



- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath</pre>

NSNumber *num = [[tableItems objectAtIndex:[indexPath indexAtPosition:1]] objectAtIndex:0];

NSString *identifer = [num stringValue];

MyOriginalCell *cell = (MyOriginalCell *)[tableView dequeueReusableCellWithIdentifier:identifer];

if (cell == nil) {

UIViewController *vc;

vc = [[UIViewController alloc] initWithNibName:@"MyOriginalCell" bundle:nil];

cell = (MyOriginalCell *)vc.view;


return cell;


Comments are closed.