this is just about to drive me nuts. I’m trying to make a simple grouped table and whenever I run it I get this error:
-[__NSCFConstantString objectAtIndex:]: unrecognized selector sent to instance 0x489c
Here’s the code that’s throwing the line (I put the exact line in asterisks):
-(UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *newSpecCell = @"newSpecCell";
NSUInteger section = [indexPath section];
NSUInteger row = [indexPath row];
NSString *key = [segmentArray objectAtIndex:section];
NSArray *names = [specsDictionary objectForKey:key];
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:newSpecCell];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:newSpecCell];
}
cell.textLabel.text = [names objectAtIndex:row]; // <---
return cell;
}
From my logic I’m asking for the objectAtIndex from an array but the error says I’m sending it to a constant string.
I’ve tried a few things (like making a string from [names objectAtIndex:row] but it doesn’t seem to make any difference. Also, if I use NSLog to show the values in names it shows them correctly so I know the array contains the values I need.
Simple problem of array being incorrectly populated. Thanks to Maddy I figured it out quickly enough.
I simply removed the commented rows and modified the cell.textlabel.text as shown and all was well!