1

私のオブジェクトには予約語noがあるため、述語で %K を使用する必要があります。%K を唯一の条件として使用すると機能しますが、チェーンまたは条件に追加すると例外が発生します。

これにより例外が発生します。

NSPredicate *predicateTemplate = [NSPredicate  predicateWithFormat:@"first_name CONTAINS[cd] %@ OR last_name CONTAINS[cd] %@ OR nickname CONTAINS[cd] %@ OR group == %i OR %K = %i", searchText, searchText, searchText, value, value, @"no", value];

例外:

*** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<Contact 0x828dbd0> valueForUndefinedKey:]: this class is not key value coding-compliant for the key (null).'

これは機能します:

NSPredicate *predicateTemplate = [NSPredicate  predicateWithFormat:@"%K = %i", @"no", value];
4

1 に答える 1