I really don't know how to title this question, so my apologies in advance....
Building a flash card app. The deck of cards can be filtered through preferences to include/exclude certain continents. I set the filter to include only one continent, then I play the game successfully. After finishing my deck, I decide to include a second continent. Fail.
I'm using a TableViewController to display the six continents. Prototype cell is "Right detail". textLabel.text
is Continent name. detailText.text
shows inclusion/exclusion state.
All continents start as "include". Click on a row, it toggles on/off.
I can make changes on the screen, save the settings, come back and make more changes without crashing. App only crashes after going through the deck one time, be it 10 cards or 100.
Error Message: -[__NSArrayI addObject:]: unrecognized selector sent to instance
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
NSString *name = cell.textLabel.text;
if ([[GameSettingsObject sharedInstance].chosenContinents containsObject:name]) {
if ([[GameSettingsObject sharedInstance].chosenContinents count]>1) {
[[GameSettingsObject sharedInstance].chosenContinents removeObject:name];
cell.detailTextLabel.text = @"exclude";
}
} else {
[[GameSettingsObject sharedInstance].chosenContinents addObject:name];
cell.detailTextLabel.text = @"include";
}
}
Any ideas?
You can add objects only into mutable array. So I think that your array becomes to NSArray somehow. Check that.