OGeek|极客世界-中国程序员成长平台

标题: iOS,核心数据 : set argument is not an NSSet error when counting an NSSet [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-13 03:16
标题: iOS,核心数据 : set argument is not an NSSet error when counting an 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

提前谢谢你。



Best Answer-推荐答案


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

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

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






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://sqlite.in/) Powered by Discuz! X3.4