gpt4 book ai didi

ios - 如何解决 NSPredicate error 'Can' t use in/contains operator with collection 8 (not a collection)

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:50:13 25 4
gpt4 key购买 nike

我尝试根据初始查询的心情来预测我的核心日期,所有心情都设置为 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== 作为比较器。

关于ios - 如何解决 NSPredicate error 'Can' t use in/contains operator with collection 8 (not a collection),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20606453/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com