NSPredicate that is the equivalent of SQL's LIKE

后端 未结 3 1562
忘了有多久
忘了有多久 2020-12-07 20:21

I\'m looking for a way to use NSPredicate to set a LIKE condition to fetch objects. In addition to that, an OR would be useful as well

3条回答
  •  太阳男子
    2020-12-07 20:39

    NSString *_mySearchKey = @"James";
    NSPredicate *_myPredicate = [NSPredicate predicateWithFormat:@"(firstname CONTAINS[cd] %@) OR (lastname CONTAINS[cd] %@)", _mySearchKey, _mySearchKey];
    

提交回复
热议问题