NSPredicate - filtering values based on a BOOLEAN stored value

后端 未结 8 956
终归单人心
终归单人心 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:56

    For me, on SWIFT 3.0 use NSNumber and %@ didn't work, I had to use integer values:

    NSPredicate(format: "yourAttributeName == %i", yourBooleanValue ? 1 : 0)
    
    0 讨论(0)
  • 2021-02-03 20:58

    For me it worked like this

    NSPredicate *predicate = [NSPredicate predicateWithFormat:@"(isComplete LIKE[c] %@)",[NSString stringWithFormat:@"%@",[NSNumber numberWithBool:YES]]];
    
    0 讨论(0)
提交回复
热议问题