I’m having problems releasing UIView controller, this is my code.
When I press a button, I put a View on the screen in front of everything:
viewT = [[PersonalViewController alloc] initWithNibName:@"PersonalViewController" bundle:[NSBundle mainBundle]];
//In this moment the retainCount is 1
[[AppDelegate appDelegate].window insertSubview:viewT.view aboveSubview:[AppDelegate appDelegate].dockController.view];
[viewT release];
//Now the retain count is 3!
//... After some code, when the user press another button, I want to release the view
[viewT.view removeFromSuperview];
//After this line, the object stills there, with a retain of 2.
So something it’s happening and I don’t understand. I’ve been reading guides about memory and I’ve never had this doubt before, what am I doing wrong? How can I completely release viewT???
object you own
Memory Management Programming Guide
So, you need only one line of code