Hi I was wanted to do Application witch have a root template view with a nice logo on top or something adn load other views just below
(here is what I have right now: Test App
)
But I have a little problem. If I’ll remove a comment in file TestAppDelegate.m on line 58
//[currentView release];
Application will crash with bunch of errors when I try to switch views.
But if I comment this line Project analyzer is telling me that I have a potential leak
with currentView variable.
Can somebody spare some time and see in that code what I did wrong?
The problem is that you are only adding
currentView.viewas a subview so that is being retained elsewhere butcurrentViewitself is not. This means that when you release it, it is consequently dealloc’d and its view will have difficulty working without it.One solution would be to have
currentViewas an instance variable and create a property for it so that the memory mangement is done for you.and then replace a line like
with
This will release the old view controller before retaining the new one. Then lastly don’t forget to release
currentViewin thedeallocmethod of the class.