30 April 2010

Empty Implementation of viewDidUnload?

I'm wondering about something from page 97 of the text--the method "viewDidUnload" contains no statements. I noticed that in the stub code generated by XCode for this method, a call to [super viewDidUnload]; was included. Don't we want that, or is it just not needed here? The IPhone Simulator will run CityGuide (seemingly just fine) either way, but it seemed odd to me that the textbook would call for an empty method body.

1 comment:

  1. Good question! Note that this method was the same (empty) for HelloWorld on page 32. As you suggest, it seems not to matter. The question could be answered decisively by finding the code for the viewDidUnload method for the UIViewController (and its ancestor classes), if anyone wants to look for it. I suspect that only a user-written class like AddCityController or HelloWorldViewController would be creating and retaining subviews to begin with, so (unlike the crucial [super dealloc] call), [super viewDidUnload] has no effect here.

    ReplyDelete