I have a UITableViewController which is supposed to fetch data in the background and then refresh the UITableView. However when I run the update method in the background it breaks all transition animations in the entire app (Slides when pushing view controllers on to the navigation stack). Weirdly, the exact same model works in other classes very similar to this one.
Here is the call I’m using for background updating:
[self performSelectorInBackground:@selector(updateData) withObject:nil];
However this works, but is of course not done in the background:
[self updateData];
And finally the method being run:
- (void)updateData{
updating = YES;
[progress show:YES];
dataSource = [[NetworkHandler sharedInstance:self] getRaces];
[progress hide:YES];
updating = NO;
[self.tableView reloadData];
}
The updating flag is not in any way an attempt at a semaphore, merely a way to ensure that the view doesn’t get updated twice in case the user switches back and forth between views. 😉
[self.tableView reloadData];looks like it could cause some kind of threading issue. All updates to the UI should be done in the main thread. So this should work:[self.tableView performSelectorOnMainThread:@selector(reloadData)];