problem for getting the memory leak in frame setting
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 开发者_Python百科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 addViewController
and currentTabView
in a view controller, then declare them as a property, and use, self.addViewController
and self.currentTabView
when assigning new values.
Then compiler will automatically handle releasing and deallocating. surely you have to release them in dealloc.
self.addViewController = [[ProAddViewController alloc] initWithNibName:@"ProAddViewController"
bundle:nil];
[addViewController.view setFrame:[[UIScreen mainScreen] applicationFrame]];
self.currentTabView = addViewController ;
精彩评论