I have a problem: I am programming an app that is using a searchBar and a tableView.
When I click the search bar, type some string to search for, as soon as I hit the cancel button, or delete all the search terms and click the tableView again my app crashes.
When I run the app in the iOS Simulator, it doesn't crash when doing this.
When I run the app on my iPhone via xcode, it doesn't crash when doing this.
I don't really understand the device log and I wanted to ask if there is any way to find out what's going terribly wrong and why this is not happening when doing it via xcode. Please help me!
PS: One of the device logs: (Maybe you guys understand this)
EDIT: Here's the code of the searchDisplayControllerDidEndSearch method:
- (void)searchDisplayControllerDidEndSearch:(UISearchDisplayController *)controller
{
[self.navigationController setNavigationBarHidden:NO animated:YES];
[UIView beginAnimations:@"DeactivateSearch" context:nil];
[UIView setAnimationDuration:0.4];
[self.attractionsTableView setFrame:CGRectMake(0, 43, 320, 362)];
[UIView commitAnimations];
NSFetchRequest *fetchRequest = [[self fetchedResultsController] fetchRequest];
[fetchRequest setPredicate:nil];
NSError *error = nil;
if (![[self fetchedResultsController] performFetch:&error]) {
// Handle error
NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
abort();
}
[self setSearchIsActive:NO];
return;
}
UPDATE: The search bar does NOT crash if no text was typed. So simply activating the searchBar and deactivating it without typing works. But as soon as I have typed a single character the deactivating process crashes the app.
I found the answer myself..
In one of my custom cells I released something too often and thus the app crashed when the UISearchDisplayController was releasing the UITableView for the search results.