If I have 2 controllers; List and detail controller, what is the correct way to handle memory management for these 2 controllers?
I mean at what point should release be called on them?
Also in case my list controller is dynamic (i.e. data gets called from ext web service) and some data is passed to detail controller, where exactly should I write the code to retrieve/display the data in detail controller. I mean should it be viewDidLoad or viewWillAppear ?
Any examples would be great.
There is no single answer. But my answer is….
viewWillAppearTake a detail view which is almost never used. So maybe you decide to create one each time it’s used and destroy it after every use.
Take another detail view which may be used frequently. You decide create it once and just re-use it. Maybe you even destroy it on low-memory warnings and re-create it the next time it’s used. In this case, you can’t depend upon
viewDidLoadbeing called each time theUsing
viewWillAppearmakes my code more consistent and makes it easier to make a change when I realize that detail view is being called a lot more than I expect. I should re-use it instead of creating it every time.As to when you should release them… that really depends on what perspective. How often is it used? How much memory does it take to simply exist? How much work does it take to re-create?