UINavigationController leak/understanding popViewController
- by Kamchatka
Hello,
I have a navigation controller and a table view. When someone click on the table view, I do the following:
MyViewController *myViewController = [[MyViewController alloc] initWithImage:image];
[image release];
[self.navigationController pushViewController:myViewController animated:YES];
[myViewController release];
myViewController will retain the image.
Now, if I go back and forth in the NavigationController, I get a leak because a new MyViewController gets created each time and apparently the popViewController doesn't release the myViewController.
My question:
Why doesn't popViewController release the controller?
How should I handle that? Put the myViewController as a member of my class and check if it already exists instead of creating it each time?
Thanks in advance for your help,