iOS,核心数据 : set argument is not an NSSet error when counting an NSSet

标签 ios cocoa-touch core-data nsset

当列出相同的 tableView 时,有时会发生这种错误,我的意思是有时是,有时不是。当我尝试检查检索到的 NSSet 是否包含任何对象时:

if(coin.dublicates.count > 0)

我得到错误:

*** -[NSMutableSet unionSet:]: set argument is not an NSSet'

出现这种错误的原因是什么? 整个方法列表:

if(period.regions.count == 0) {

    for(Nominal *nominal in period.nominals) {

        if(nominal.coins.count>0) {

            counter+=[[nominal.coins filteredSetUsingPredicate:[NSPredicate predicateWithFormat:@"listed==%@",[NSNumber numberWithBool:YES]]]count];
            for(Coin *coin in nominal.coins)
            {

                if(coin.dublicates.count > 0) {

                    counter+=coin.dublicates.count;
                }
            }
        }
    }
}

截图:

enter image description here

提前谢谢你。

最佳答案

在评估其计数之前验证 NSSet 不为 nil。

if (coin.dublicates) {
    // Do stuff
} 

关于iOS,核心数据 : set argument is not an NSSet error when counting an NSSet,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26872814/

相关文章:

sql - SQL 表达式的核心数据代码

ios - 自定义 UITableViewCell 不更新

cocoa-touch - 当我快速点击 UITextField 时,为什么 UIKeyboard 没有出现?

iphone - 可能是 "reset"UIDatePicker 突出显示的月/日/年吗?

android - 在查看/解析 IIS 日志时,如何过滤掉来自移动应用程序而不是 Web 浏览器的对 API 的直接调用

iphone - 进行核心数据迁移时内存不足

ios - 核心数据-根据应用程序版本不同的数据

ios - 向 UIScrollView 中的标准 Pan Gesture Recognizer 添加功能

iphone - 从 UISegmentedControl 中删除白色渐变

ios - 如何清除使用 Kingfisherin UITableView 加载的图像的内存和磁盘缓存?