ios - 在coreData中查询一个NSNumber字段
黄舟
黄舟 2017-04-18 09:34:02
0
1
262

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

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

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

控制台输出的信息是

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

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

黄舟
黄舟

人生最曼妙的风景,竟是内心的淡定与从容!

reply all(1)
黄舟

NSNumber Use the double equal sign directly:

[NSPredicate predicateWithFormat:@"ctype == %@", @7]
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!