I. Why do I need to call "Super viewdidload"-(void) didreceivememorywarning {
[Super didreceivememorywarning];
}
-(Void) viewdidload {
[Super viewdidload];
}
In the above Code, what do I need to call the corresponding methods of the parent class?
Taking viewdidload as an example, viewdidload in the parent class (Super) will help you do some initialization work, for example, a is the parent class, B inherits, B creates and initializes some Members in the viewdidload method. c inherits B again. If C does not call the viewdidload method of super when calling viewdidload, some Members are not initialized, and problems may occur.
Ii. Call time of [Super viewdidload] and [Super viewdidunload:
(1) In iPhone/iPad programming, the viewdidload method is used to initialize the processing when trying to load the view in the controller.
There are two ways of writing in iPhone 4 and iPad basic development tutorial
Method 1:
-(Void) viewdidload {
[Super viewdidload];
// Other code
}
Method 2:
-(Void) viewdidload {
// Other code
[Super viewdidload];
}
However, I think the first method is more desirable. First, call the parent class to load the code before loading itself.
(2) The viewdidunload method is used to release resources when the view is detached, for example, releasing the output port and memory.
-(Void) viewdidunload {
// Release code, such as Self. xxx = nil;
[Super viewdidunload];
}
Why do we need to call "Super viewdidload"