Search code examples
iosios5

Is viewDidUnload & didReceiveMemoryWarning optional?


Is the viewDidUnload & didReceiveMemoryWarning optional if no extra logic is added to these 2 functions (i.e. save to remove the following codes)?

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}

- (void)viewDidUnload {
    [super viewDidUnload];
}

Solution

  • Yes, if no extra logic is added to these 2 functions.

    But you need to inspect carefully the whether any logic is necessary?

    You also need to understand when these function is run in this document by Apple

    The View Controller Life Cycle

    Then you decide whether you need any extra logic.