views:

58

answers:

1

If I have a set of custom UIViewControllers that I release in a high level application "restart" routine, would a good way to release their views be to set

self.view = nil;

in the dealloc method?

A: 

I'm not sure where your views are, but you usually would want to remove them from superview (if they have one)

[someView removeFromSuperview];

if it's retained by something else other than its superview, you'd want to release it

[someView release];

assuming your retainCount is then 0, dealloc will be called (in 99% of the cases, you should never call dealloc yourself)

then yes, you would want to nil it.

someView = nil;

then you can recreate your views or whatever you want to do.

Neil Daniels
I do remove them from the superview, but that just affects display. They are not retained anywhere else, other than the .view property of the controllers. My gut feeling looking at my object allocation graph rising was that views were not being freed when the UIViewControllers were getting released, but I am not sure. I am not callng dealloc directly, just putting that line in dealloc method so the views get released.
Michael