If I am receiving memory warnings where exactly I have to release all my views & data ?
Whether I have to release in
- (void)didReceiveMemoryWarning
or in
- (void)viewDidUnload
If I am receiving memory warnings where exactly I have to release all my views & data ?
Whether I have to release in
- (void)didReceiveMemoryWarning
or in
- (void)viewDidUnload
For iPhone OS 3.0 and later viewDidUnload
maybe called during low memory situtations so best to release views in viewDidUnload, just note that for custom views, create them at viewDidLoad instead of init method of the class.
didReceiveMemoryWarning
is used more for releasing custom data structures instead of releasing views.
- (void)didReceiveMemoryWarning
This is supposed to be used only on things that you dont and wont need anymore so put here what is strictly innecessary, for instance if you are not using a view anymore and maybe it wasnt released you can release it here so when the memory warning comes it will be released.
- (void)viewDidUnload
Here you make sure that the views will be released in case they are referenced additionally by a view controller. You can refer to this question: When to use viewDidUnload