I am implementing an iPhone app.for that,creating a common view controller throughout the application and i am changing my views according to the requirements. for that i am writing the code like
addViewController = [[ProAddViewController alloc] initWithNibName:@"ProAddViewController" bundle:nil];
[addViewController.view setFrame:[[UIScreen mainScreen] applicationFrame]];
currentTabView = addViewController ;
and then when ever i want to add new view for the currentTabView, i am releasing the previous one then adding new view controller’s view to the currentTabView.finally i am releasing the currentTabView in dealloc().
i am getting a memory leak in the line shown below.
[addViewController.view setFrame:[[UIScreen mainScreen] applicationFrame]];
Can any one please help me out? Thanks in advance.
An easy way can be,
if you are using the
addViewControllerandcurrentTabViewin a view controller, then declare them as a property, and use,self.addViewControllerandself.currentTabViewwhen assigning new values.Then compiler will automatically handle releasing and deallocating. surely you have to release them in dealloc.