Using xcode 4.2 for iPhone app, without ARC —
When I create an outlet using the interface builder xcode adds two lines of code to my viewController. One in viewDidUnload: — [self setMyOutlet:nil] and second in dealloc — [myOutlet release].
I understand the latter (the release). But why set the outlet to nil in viewDidUnload. Doesn’t viewDidUnload get called before dealloc and won’t setting the outlet to nil negate the release operation in dealloc? Setting to nil makes sense I would think for building a Mac application which is using garbage collection — but it doesn’t make sense for an iPhone app.
Why does the interface builder do this? Should I delete the lines which set the outlets to nil?
viewDidUnloadmay be called and may be not called. It depends on the current memory usage.deallocis a place where you should clean all your properties (like arrays, custom objects). InviewDidUnloadyou clean views and perhaps objects created to support the view.viewDidUnloadmean that your view is unloaded (but not whole view controller) and it may be created and loaded again (in viewDidLoad, of course) in the future.releasing
Unloaded