我真的不知道如何给这个问题起标题,所以我提前道歉....
构建闪存卡应用。可以通过偏好过滤纸牌以包括/排除某些大洲。我将过滤器设置为仅包括一个大陆,然后我成功玩了游戏。完成甲板后,我决定包括第二个大陆。失败。
我正在使用 TableViewController 来显示六大洲。原型(prototype)单元是“正确的细节”。 textLabel.text
是大陆名称。 detailText.text
显示包含/排除状态。
所有大洲都以“include”开头。单击一行,它会打开/关闭。
我可以在屏幕上进行更改,保存设置,然后返回并进行更多更改而不会崩溃。应用仅在检查一副牌后崩溃,无论是 10 张还是 100 张。
错误信息:-[__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";
}
有什么想法吗?
最佳答案
您只能将对象添加到可变数组中。所以我认为你的数组以某种方式变成了 NSArray。检查一下。
关于ios - 该方法在玩纸牌游戏之前有效 n 次,之后第一次失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30169354/