Posted by: bearc0025 | March 25, 2010

How To Do Amazingly Simple Searches With NSArray & NSPredicate

Good, straight forward article on NSPredicate use…

How To Do Amazingly Simple Searches With NSArray & NSPredicate.

Here are the steps required to search arrays with NSPredicate:

  • Find or create an NSArray full of objects with interesting properties
  • Create an NSPredicate object with the search query that you want to use
  • You can use this NSPredicate object to either filter the array or create a new array with a subset of data
  • NSPredicate *predicate = [NSPredicate predicateWithFormat:@"dept == Dev"];
    NSArray  *devEmps = [emps filteredArrayUsingPredicate:predicate];
    
    
    
    Advertisements

    Leave a Reply

    Fill in your details below or click an icon to log in:

    WordPress.com Logo

    You are commenting using your WordPress.com account. Log Out / Change )

    Twitter picture

    You are commenting using your Twitter account. Log Out / Change )

    Facebook photo

    You are commenting using your Facebook account. Log Out / Change )

    Google+ photo

    You are commenting using your Google+ account. Log Out / Change )

    Connecting to %s

    Categories

    %d bloggers like this: