Click here to Skip to main content
12,352,091 members (31,630 online)
Click here to Skip to main content
Add your own
alternative version

Stats

10.3K views
1 bookmarked
Posted

Avoid NSFetchedResultsController crashing app when popping

, 7 Jan 2012 CPOL
Rate this:
Please Sign up or sign in to vote.
Stop app crashing with "-[MyClass controllerWillChangeContent:]: message sent to deallocated instance"?
Why is my app crashing with "-[MyClass controllerWillChangeContent:]: message sent to deallocated instance"?

The accepted answer is to set the NSFetchedResultsController to nil when the view disappears.

-(void)viewWillDisappear:(BOOL)animated {
	self.fetchedResultsController = nil;
}

This, for me at least, resolved one problem and created a dozen more, Lists not displaying, deleting objects and alike. So I rolled back and took a closer look. The real problem occurred when I popped the UITableViewController. So taking the idea that setting the NSFetchedResultsController to nil could help, I set the NSFetchedResultsController to nil before popping the view and everything feel back into place.

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
	...
	self.fetchedResultsController = nil; //This is the line that fixed issue
	[self.navigationController popViewControllerAnimated:YES];
}

I hope this tip has helped.

Rob

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

RobCroll
Australia Australia
Enjoying life developing mobile device software for Contractors Apps and Ezi App.

I also teach C#, Java and Project Management a couple of evenings a week.

Prior to moving to DCB, I'd been a Windows software developer for nearly 15 years

You may also be interested in...

Comments and Discussions

 
-- There are no messages in this forum --
| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.160621.1 | Last Updated 7 Jan 2012
Article Copyright 2012 by RobCroll
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid