I have a navigation based app. The screen List has a UITableView
with a list of books. The list of books is in a property NSArray
that was built dynamically by executing an HTTP request. When one clicks in one of the rows in the List, one'll navigate to the screen Details. Let's say there is a memory warning at this point. When you come back to the screen List, the NSArray
is nil because viewDidUnload
was called, so the List will be empty.
What is the correct way to handle this situation? Should I not set the NSArray
to nil in viewDidUnload
?
Typically you will only nil out properties for your IBOutlet UI elements. You can also safely clean up anything that you can recreate in -viewDidLoad
. But generally speaking, this method is only for cleaning up and freeing memory related to the view, not the view controller.