I wonder why in these examples there is always a [super someMethod] inside of the Method that has the exact same name:
- (void)viewDidLoad {
[super viewDidLoad];
// some code
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
}
- (void)viewDidUnload {
[super viewDidUnload];
}
I know that those messages are sent to the superclass, but what’s the deal with this?
This is simply so that the superclass can do what it always does. It’s a way for both your class and the superclass to receive the same message. In some situations, you are required to implement your own behaviour and invoke the behaviour of the superclass.
For example, the superclass will have its own memory cleanup routines which would otherwise be ignored if you did not invoke
[super didReceiveMemoryWarning].