Search code examples
iosuitableviewnsarraysigabrtnsindexpath

NSArray SIGABRT


NSString* year = [self.years objectAtIndex:[indexPath section]];

//get algorithms for that year
NSArray* algorithmSection = [self.algorithmNames objectForKey:year];

NSLog(@"%@", indexPath);

//get specific algorithm based on that row
cell.textLabel.text = [algorithmSection objectAtIndex:indexPath.row];

return cell;

For whatever reason, when I compile this, I get a SIGABRT error. It happens on the

cell.textLabel.text

line. Error:

2011-08-29 19:26:21.273 xxxxxxxxxxx[1431:b303] 2 indexes [0, 0]

2011-08-29 19:26:21.274 xxxxxxxxxxxxx[1431:b303] -[__NSCFDictionary objectAtIndex:]: unrecognized selector sent to instance 0x4ba2370

2011-08-29 19:26:21.277 xxxxxxxxx[1431:b303] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFDictionary objectAtIndex:]: unrecognized selector sent to instance 0x4ba2370' terminate called throwing an exception


Solution

  • Your algorithmSection variable, which your code expects to be an NSArray, is actually an NSDictionary, which does not respond to the selector -objectAtIndex:.