Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to optimize core data NSFetchedResultsController with UISearchBar?
    primarykey
    data
    text
    <p>I have a <code>UISearchBar</code> that is hooked up with a <code>NSFetchedResultsController</code>.</p> <p>It searches as the user enters text into the search bar. I notice for the first few letters it lags, but then it quickens up and their is no lag. Is there any way to reduce the initial lag and make the search very snappy?</p> <pre><code>- (void)filterResultsUsingString:(NSString *)filterString { self.billingSearchText = filterString; NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init]; NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"name" ascending:YES]; NSArray *sortDescriptors = [[NSArray alloc] initWithObjects:sortDescriptor, nil]; [fetchRequest setSortDescriptors:sortDescriptors]; NSEntityDescription *entity = nil; if ([self.billingSearchCategory isEqualToString:@"icd9"]) { entity = [NSEntityDescription entityForName:@"ICD9" inManagedObjectContext:managedObjectContext]; } else if ([self.billingSearchCategory isEqualToString:@"cpt"]) { entity = [NSEntityDescription entityForName:@"CPT" inManagedObjectContext:managedObjectContext]; } [fetchRequest setEntity:entity]; [sortDescriptors release]; [sortDescriptor release]; self.fetchedResultsController = [[NSFetchedResultsController alloc] initWithFetchRequest:fetchRequest managedObjectContext:managedObjectContext sectionNameKeyPath:nil cacheName:@"Root"]; [fetchRequest release]; NSPredicate *predicate =[NSPredicate predicateWithFormat:@"(name contains[cd] %@) OR (code contains[cd] %@)", self.billingSearchText, self.billingSearchText]; [self.fetchedResultsController.fetchRequest setPredicate:predicate]; NSError *error = nil; if (![[self fetchedResultsController] performFetch:&amp;error]) { NSLog(@"Unresolved error %@, %@", error, [error userInfo]); exit(-1); // Fail } [self.tableView reloadData]; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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