views:

43

answers:

2

Hi everyone, I have a question regarding to self.view in a UIViewController.

First, in my app, everything is created programmatically. And normally I create self.view in the loadView method:

self.view = [[UIView alloc]initWithFrame:SCREEN_FRAME]autorelease]; // SCREEN_FRAME is a constant

At this moment, the retain count of self.view is 1.

So, my question is, do I have to release self.view when I'm done with the view controller? If so, where should I release it?

Thanks very much in advance :)

+1  A: 

That is being done for you by the implementation of UIViewController, just make sure you call [super dealloc] in your dealloc method.

willcodejavaforfood
Thanks for the answer. :)
Sunny
A: 

self.view is added autorelease pool and object will be release when pool is released. you don't need to release explicitly. If you add object to pool and release manually you will get exception double dealloc (since object is getting released twice)

Girish Kolari