Second rule: release Outlets in viewDidUnload


#1

On page 114 the second rule says: For a view controller, release any outlets and set to nil in viewDidUnload. Is there also a rule for the AppDelegate? What about the outlets there?


#2

Nope, the AppDelegate doesn’t have a view. UIViewController has a view, and in low memory conditions, that view is released. To do extra clean up, the view controller then gets sent the message viewDidUnload. Subclasses of UIViewController can override this method to do that cleanup.

The AppDelegate will never get sent this message. And that’s a good thing, because the class AppDelegate inherits from, NSObject, doesn’t implement this method.


#3

Ok! Thank you. So I only have to release any IBOutlets of my AppDelegate in dealloc()?!


#4

Correct, however, note, that the app delegate will never get deallocated as it exists the entire time the application is running.