On a number of view controllers in my app, it seems to get overreleased such that when I pop the view controller (i.e. the user hits "back"), I get a crash. I am using fairly standard code to declare and load the UIViewController:
MyViewController *myVC = [[MyViewController alloc] initWithNibName:@"MyViewController" bundle:nil];
NSManagedObjectContext *context = [self managedObjectContext];
if (!context) {
// TODO: handle the error
}
// pass the managed object context to the view controller.
myVC.managedObjectContext = context;
myVC.variable1 = self.variable1;
// Pass the selected object to the new view controller.
[self.navigationController pushViewController:myVC animated:YES];
[myVC release];
And then I get this error:
2010-08-05 16:28:50.733 MyApp[2510:207] *** -[CALayer release]: message sent to deallocated instance 0x719c260
According to Instruments, I have the following memory actions:
- Malloc (1) in the function which I posted above.
- Zombie (-1) in some Objective-C area which I presume is the memory management code.
Any idea what would be causing this? For now I have been simply not release
-ing the view controllers which are causing this problem, but I know this cannot be good since you should be releasing anything that you alloc.