首页 > 在coreData中查询一个NSNumber字段

在coreData中查询一个NSNumber字段

需求是这样的要在本地数据库中获取全部ctype为7的数据
数据库中的ctype类型为NSNumber

以下是我的代码 大部分能正确运行 在少数我不知道原因的情况下会crash

 NSPredicate *predicate = [NSPredicate predicateWithFormat: @"ctype CONTAINS %@", @"7"];
    

控制台输出的信息是

    Can't use in/contains operator with collection 7 (not a collection)
    

我应该如何改进这段代码呢?


NSNumber 直接用双等号:

[NSPredicate predicateWithFormat:@"ctype == %@", @7]
【热门文章】
【热门文章】