Objective-C Top or bottom super call in overridden method
ios, objective-c
Solution
In the case of view lifecycle you should call it first in the method because you want the super class to finish the setup before you do what you need.
Although in the case of dealloc you should call super at the end of the method because you want to cleanup before the super class cleans up.
Problem
In objective-C should I call the super view override method at the top or the bottom of the method? Whats the difference? For example: At the top of the method: ``` - (void)viewDidLoad { // HERE [super viewDidLoad]; //Init the table view UITableView *aTableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, 100, 400)]; aTableView.delegate = self; aTableView.dataSource = self; aTableView.backgroundColor = [UIColor clearColor]; self.tableView = aTableView; [aTableView release]; } ``` Or at the bottom of the method: ``` - (void)viewDidLoad { //Init the table view UITableView *aTableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, 100, 400)]; aTableView.delegate = self; aTableView.dataSource = self; aTableView.backgroundColor = [UIColor clearColor]; self.tableView = aTableView; [aTableView release]; // HERE [super viewDidLoad]; } ```