Ios 如何解决NSPredicate错误';Can';t将in/contains运算符用于集合8(非集合)

Ios 如何解决NSPredicate错误';Can';t将in/contains运算符用于集合8(非集合),ios,iphone,objective-c,nspredicate,Ios,Iphone,Objective C,Nspredicate,我试图根据初始查询中的语气来断言我的coredate,所有的语气都设置为8。 我将从0-7每秒打电话更新tableview 但是我有 Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Can't use in/contains operator with collection 8 (not a collection)' 我应该使用CONTAINS还是其他运算符来谓词 NSString

我试图根据初始查询中的语气来断言我的coredate,所有的语气都设置为8。 我将从0-7每秒打电话更新tableview

但是我有

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Can't use in/contains operator with collection 8 (not a collection)'
我应该使用CONTAINS还是其他运算符来谓词

NSString* filter = @"%K CONTAINS[cd] %@";
NSPredicate *getMoodPred = [NSPredicate predicateWithFormat:filter, @"mood", mood];
NSLog(@"getmood %@",getMoodPred); //getmood mood CONTAINS[cd] "7"
NSArray *getMoodArray = [[VPPCoreData sharedInstance]allObjectsForEntity:@"Song" orderBy:Nil filteredBy:getMoodPred];

这可能意味着
mood
属性存储为数字,而不是字符串。“CONTAINS”仅适用于字符串。以下谓词应起作用:

NSNumber *mood = @(7);
NSString *filter = @"%K == %@";
NSPredicate *getMoodPred = [NSPredicate predicateWithFormat:filter, @"mood", mood];

使用rhs上的
NSNumber
=
作为比较器。

假设我有一个整数值为2000的字段。如果我写2000,它会显示结果。是否有任何方法可以获得整数字段的子字符串匹配?我想在键入2、20或200时获取值。如何跳过写完整的数字?有什么办法吗?@JamshedAlam:我认为那是不可能的。子字符串匹配仅适用于字符串,而不适用于整数。