Note that there are some explanatory texts on larger screens.

plurals
  1. PONSFetchedResultsController causes iPhone 3G to freeze
    text
    copied!<p>I have a UISearchDisplayController that modifies the NSPredicate of the NSFetchRequest whenever a the searchBar is changed. This fetch request is associated with a NSFetchedResultsController that updates the searchResultsTableView.</p> <p>These work without a hitch on iOS devices >= iPhone 3GS, but fails miserably on iPhone 3G devices by freezing the UI completely once the searchBar contents is even slightly changed. This even happens if the persistent store has no records within it whatsoever.</p> <p>The fetch is actually performable because the app doesn't quit due to the exit(-1).</p> <p>Anyone seen such an issue or have an idea how to deal with this problem?</p> <p>(Doing this on iOS 4.3SDK with deployment target set at 4.0. iPhone 3G that hangs in question is at OS 4.2.1.)</p> <hr> <p>Code for creating Search FRC:</p> <pre><code>-(NSFetchedResultsController *)searchFetchedResultsController { if (__searchResults) { return __searchResults; } NSFetchRequest *fetchrequest = [[NSFetchRequest alloc] init]; [fetchrequest setEntity:[NSEntityDescription entityForName:@"Product" inManagedObjectContext:[[LBCCacheManager sharedLBCCacheManager] managedObjectContext]]]; [fetchrequest setFetchBatchSize:20]; [fetchrequest setPropertiesToFetch:[NSArray arrayWithObjects:@"title", @"slug", nil]]; NSSortDescriptor *recentSort = [NSSortDescriptor sortDescriptorWithKey:@"dealsCount" ascending:NO]; [fetchrequest setSortDescriptors:[NSArray arrayWithObject:recentSort]]; NSFetchedResultsController *fetchedcontroller = [[NSFetchedResultsController alloc] initWithFetchRequest:fetchrequest managedObjectContext:[[LBCCacheManager sharedLBCCacheManager] managedObjectContext] sectionNameKeyPath:nil cacheName:nil]; fetchedcontroller.delegate = self; [__searchResults release], __searchResults = nil; __searchResults = [fetchedcontroller retain]; [fetchedcontroller release]; [fetchrequest release]; return __searchResults; } </code></pre> <p>Code for whenever searchBar is changed:</p> <pre><code>-(BOOL)searchDisplayController:(UISearchDisplayController *)controller shouldReloadTableForSearchString:(NSString *)searchString { if ([controller.searchBar.text length] &gt; 0) { [self contentFilter:controller]; } return YES; } -(void)contentFilter:(UISearchDisplayController *)controller { [[self searchFetchedResultsController].fetchRequest setPredicate:[NSPredicate predicateWithFormat:@"title contains[c] %@", controller.searchBar.text]]; NSError *error = nil; if (![[self searchFetchedResultsController] performFetch:&amp;error]) { NSLog(@"ERROR"); exit(-1); } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload