Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is viewDidUnload & didReceiveMemoryWarning optional?

Tags:

ios

ios5

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];
}
like image 465
Raptor Avatar asked Apr 19 '12 03:04

Raptor


2 Answers

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.

like image 91
vietstone Avatar answered Oct 11 '22 03:10

vietstone


Yes.

According to the documentation, the default implementation of didReceiveMemoryWarning "attempts to release the view controller’s view". So if you don't need anything else to happen, then you can delete the code and rely on the default.

like image 23
Andrew Schleifer Avatar answered Oct 11 '22 04:10

Andrew Schleifer