1

我试图在我的 NSPredicate 中满足 2 个条件,但出现以下错误。

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Unable to parse the format string "(whosEval == %@) AND ([age integerValue] >= 9 && [age integerValue] <= 11)"'

我知道问题出在格式上,但我找不到任何对我有帮助的问题。我做错了什么?这是我正在使用的代码。注意:年龄是核心数据实体的字符串属性。

        NSPredicate *evalPredicate = 
    [NSPredicate predicateWithFormat:@"(whosEval == %@) AND 
([age integerValue] >= 9 && [age integerValue] <= 11)", currentAthlete];
4

1 回答 1

1

可以使用以下内容:

NSPredicate *evalPredicate = [NSPredicate predicateWithFormat:@"(whosEval == %@)", currentAthlete];

在 Core Data 中运行它,然后假设 NSArray *results

结果 predicateWithBlock: 在目标 c 中解析

于 2013-11-13T04:12:22.983 回答