UINavigationController leak / understanding popViewController
I have a navigation controller and a table view. When someone clicks on a table view, I do the following:
MyViewController *myViewController = [[MyViewController alloc] initWithImage:image];
[image release];
[self.navigationController pushViewController:myViewController animated:YES];
[myViewController release];
myViewController will save the image.
Now if I go back and forth in the NavigationController I get a leak because a new MyViewController is created every time and apparently popViewController does not release myViewController.
My question is: Why does popViewController not release the controller? How can I deal with this? Put myViewController as a member of my class and check if it already exists instead of creating it every time?
Thanks in advance for your help,
+2
a source to share
2 answers