I have a UISearhBarController in my application. He is currently searching the online database, but I am changing it to search the underlying database instead. He currently uses this code:
- (void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText { if (self.billingSearchBar == searchBar) { [self.billingSearchController filterResultsUsingString:searchText]; } } - (void)filterResultsUsingString:(NSString *)filterString { self.billingSearchText = filterString; NSArray *billing_codes = [self billingSearch:self.billingSearchText searchType:self.billingSearchCategory]; self.displayedBillingSearch = billing_codes; self.billingSearch = billing_codes; [self.tableView reloadData]; } -(NSMutableArray*)billingSearch:(NSString*)searchString searchType:(NSString*)searchType { NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"%@/server/20111115/60b88126/billing_search/", [self getHost]]]; ASIFormDataRequest *request = [[[ASIFormDataRequest alloc] initWithURL:url] autorelease]; [request setPostValue:searchString forKey:@"query"]; [request setPostValue:searchType forKey:@"category"]; [request startSynchronous]; NSError *error = [request error]; NSString *responseString; if (!error) { responseString = [request responseString]; } NSMutableArray *search_results = [[NSMutableArray alloc] init]; NSDictionary *responseDictionary = [responseString JSONValue]; for (id key in [responseDictionary valueForKey:@"search_results"]) { [search_results addObject:key]; } return search_results; }
So, I already have the database setup in the main data, I just need to connect the search controller / NSFetchedResults to it. Any easy way to do this?
source share