NSPredicate multiple field search

I am trying to find several fields. Something like that:

[NSPredicate predicateWithFormat:@"(name title contains[cd] %@) AND (title contains[cd] %@",  self.searchBar.text];

The search is performed both in the name field and in the title field.

Also, if anyone knows what the search for wildcards will look like, I would appreciate it too.

I tried:

 [NSPredicate predicateWithFormat:@"* contains[cd] %@",  self.searchBar.text];

my error code is:

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Unable to parse the format string "(name contains[cd] %@) OR (title contains[cd] %@"'
+3
source share
2 answers

First, you must specify all properties for verification, since there is no fixed or universal list of properties, and in Objective-C there is no real semantic difference between a property and any other method.

-, , , , OR, AND, , - .

, , ( , name title name.)

+1

, - , . ")". :

[NSPredicate predicateWithFormat:@"(name title contains[cd] %@) AND (title contains[cd] %@)",  self.searchBar.text];

: , ONE format (. ). ( ), . , .

0

All Articles