ViewController Was Deallocated Unexpectedly
I have a very strange problem and I hope I can get some help.
I have ExpenseListViewController that has its fetechResultController, and once a row is selected from the tablev开发者_如何学运维iew, the code push detailViewController to the stack.
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
// Create and push a detail view controller.
ExpenseDetailVeiwController *detailViewController = [[ExpenseDetailVeiwController alloc] initWithStyle:UITableViewStyleGrouped];
selectedExpense = (Expense *)[[self fetchedResultsController] objectAtIndexPath:indexPath];
// Pass the selected expense to the new view controller.
detailViewController.expense = selectedExpense;
detailViewController.delegate=self;
[self.navigationController pushViewController:detailViewController animated:YES];
[detailViewController release];
}
In the detailViewController I save the context, and the callbacks of the fetchResultController on the ExpenseListViewController get called, but sometimes, not always, the listController had been deallocated.
See error message on the console:
2010-07-15 18:04:50.404 FunMobile[6396:207] *** -[ExpenseListViewController controllerWillChangeContent:]: message sent to deallocated instance 0x3bc34e0
(gdb) continue
2010-07-15 18:04:52.188 FunMobile[6396:207] *** NSInvocation: warning: object 0x3bc34e0 of class '_NSZombie_ExpenseListViewController' does not implement methodSignatureForSelector: -- trouble ahead
2010-07-15 18:04:52.189 FunMobile[6396:207] *** NSInvocation: warning: object 0x3bc34e0 of class '_NSZombie_ExpenseListViewController' does not implement doesNotRecognizeSelector: -- abort
I thought the viewController in this case should only be dealloced if it is got popped off the stack, what might be wrong here? I set the breakpoint at the dealloc method of the ExpenseListViewController, it is never called, when this error happens.
This problem happens in both OS 3.1.3 and OS 4.0 Thanks in advance in your help.
If your app is using a lot of memory all of a sudden, then the operating system will start releasing objects, particularly view controllers that use a lot of memory.
Check your application's memory situation with Instruments.
Override -didReceiveMemoryWarning:
to see if you are getting memory warnings. You can use this convenience method to start releasing unused objects.
But if your app is using a lot of memory all of a sudden, this can point to a design problem or a bug with your code. Use Instruments to track memory use throughout your app's lifespan.
Maybe you release the delegate
in ExpenseDetailVeiwController
?
This is a common mistake - you declare a non-retain property for the delegate and then release it in dealloc
.
精彩评论