Understanding NSPredicate
NSPredicate is a complex and powerful tool used to filter out the undesired instances of an entity and to display only the desired instances. We can use it to construct a SQL-like query for retrieving the desired information.
We can build NSPredicate that accepts SQL-like NSString. It can accept any number of parameters after the NSString. We can see in the preceding textDidChange
method that we have passed the text (entered in the text field of the Search Bar control) as an argument after the NSString. There are two useful methods of NSPredicate; let's have a look at them:
predicateWithFormat:
This method creates a new predicate from a formatted string. The following is the syntax for it:+(NSPredicate *) predicateWithFormatLNSString *) formatted string, argument list;
evaluateWithObject:
This method checks or evaluates a predicate with an object and returns a Boolean value YES - if the object matches with the Predicate (condition) - otherwise it returns a...