iOS CoreData NSPredicate to query multiple properties at once

后端 未结 8 1880
刺人心
刺人心 2020-12-23 22:39

I am trying to use a UISearchBar to query multiple properties of a NSManagedObject I have a NSManagedObject called Person

8条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-23 23:04

    You can append multiple search terms in an NSPredicate using the usual boolean operands such as AND/OR.

    Something like this should do the trick.

    [NSPredicate predicateWithFormat:@"name contains[cd] %@ OR ssid contains[cd] %@", query, query];
    

    Hope that helps :)

提交回复
热议问题