I read somewhere that in a programmatically created view in a UIViewController, not using Interface Builder, -viewDidLoad and -viewDidUnload should not be used. Is this right? Why? Where would I release subviews that I have retaining properties of? Or should I just not use properties for them?
EDIT: Read my comments on Rob Napier’s answer.
Create your subviews in
-viewDidLoad. If you need ivars for them then only assign their values. The reference is hold by adding the views as subviews to you main view.Then when your view is unloaded you should set your ivars to nil, because the object have been released since your view was removed and released.
So in your header
And in your implementation
If you wish you can also not release
someSubviewin-viewDidLoad, but then you have to release it in-viewDidUnloadAND-deallocsince (if I remember right)-viewDidUnloadisn’t called before-dealloc. But this isn’t necessary if you don’t retainsomeSubview.