ios - 该方法在玩纸牌游戏之前有效 n 次,之后第一次失败

标签 ios xcode6 didselectrowatindexpath

我真的不知道如何给这个问题起标题,所以我提前道歉....

构建闪存卡应用。可以通过偏好过滤纸牌以包括/排除某些大洲。我将过滤器设置为仅包括一个大陆,然后我成功玩了游戏。完成甲板后,我决定包括第二个大陆。失败。

我正在使用 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/

相关文章:

ios - 为 XML/HTML 编码 NSString

ios - 如何在 Xcode 中居中对齐自定义对象

ios - 以对象为参数的 Three20 URL 路由

ios - 为什么 SimpleAuth CocoaPod 不能与 Swift Bridging Header 文件一起使用?

ios - Jenkins错误:/usr/bin/codesign --force失败退出代码1

ios - 应用升级时将sqlite中存储的用户数据迁移到核心数据

ios - 用户界面窗口?没有成员命名边界

ios - 点击手势来关闭键盘似乎会禁用 didSelectRow

ios - 在 didSelectRowAtIndexPath 中使用 unwind segue?

iOS - 如何从容器 View 访问变量并将其传递回 View Controller