Raptor
Raptor

Reputation: 54212

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];
}

Upvotes: 5

Views: 3264

Answers (2)

Andrew Schleifer
Andrew Schleifer

Reputation: 389

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.

Upvotes: 2

vietstone
vietstone

Reputation: 9092

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.

Upvotes: 6

Related Questions