I see this code in one of the Apple samples:
- (void)viewDidLoad {
[super viewDidLoad];
// Set the content size for the popover: there are just two rows in the table view, so set to rowHeight*2.
self.contentSizeForViewInPopover = CGSizeMake(310.0, self.tableView.rowHeight*2.0);
}
-(void) viewDidUnload {
[super viewDidUnload];
self.splitViewController = nil;
self.rootPopoverButtonItem = nil;
}
I am from a C++ background, so (I think), I'm used to seeing a derived class's members processed befor开发者_运维技巧e the base class's unload method is called. What is the reason for the super viewDidUnload being called beforehand in this case, or is it simply arbitrary?
I don't think it really matters in this case. You only decrease reference counts to free iboutlets or other stuff you created in viewDidLoad. Basically this is just an extension of the code of viewDidUnload in the baseclass, and not an override or a destructor call.
Usually when you want the baseclass code to be executed also when executing methods in a subclass you call the super method first unless there is a good reason not do.
精彩评论