NSPredicate - filtering values based on a BOOLEAN stored value

后端 未结 8 1186
终归单人心
终归单人心 2021-02-03 19:55

I have a core data model object called Entry. In this I have an attribute IsFavorite.

I would like to use an NSPredicate to filter the results of my NSFetchedResultsCont

8条回答
  •  忘掉有多难
    2021-02-03 20:42

    This isn't really specific to NSPredicate... Whenever you have %@ in a format string, the corresponding value must be a pointer to an object, and BOOL doesn't qualify. So instead of passing YES, pass [NSNumber numberWithBool: YES].


    In newer versions of Xcode and the SDKs than when I originally wrote the answer, you can use @YES instead of [NSNumber numberWithBool: YES].

提交回复
热议问题