Querying Core Data with Predicates - iPhone
<p>So I'm trying to fetch objects from core data. I have list of say 80 objects, and I want to be able to search through them using a UISearchBar.  They are displayed in a table.</p>

<p>Using the apple documentation on predicates, I've put the following code in one
of the UISearchBar delegate methods.</p>

<pre><code>- (void)searchBarSearchButtonClicked:(UISearchBar *)searchBar {
  if (self.searchBar.text !=nil)
  {
    NSPredicate *predicate =[NSPredicate predicateWithFormat:@"name LIKE %@", self.searchBar.text];
    [fetchedResultsController.fetchRequest setPredicate:predicate];
  }
  else
  {
    NSPredicate *predicate =[NSPredicate predicateWithFormat:@"All"];
    [fetchedResultsController.fetchRequest setPredicate:predicate];
  }

  NSError *error = nil;
  if (![[self fetchedResultsController] performFetch:&amp;error]) {
        // Handle error
        NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
        abort();  // Fail
    }       

  [self.tableView reloadData];

    [searchBar resignFirstResponder];   
    [_shadeView setAlpha:0.0f];
}
</code></pre>

<p>If I type in the search field an exact match to the name property of one of those objects, the search works, and it repopulates the table with a single cell with the name of the object.  If I don't search the name exact, I end up with no results. </p>

<p>Any Thoughts?</p>
