IOS, TableView, NSArray datasource - when to save?
Newbie here :-)
Can anyone help me with a suggestion for the best time to write data in a UITableView/NSArray data source to a plist file?I'm thinking of the TableView's life cycle. In a small list based, single view app, which would be the best view event to make a safe copy of the data in the NSArray?
I'm thinking the about the view's dealloc method, or the viewDidUnload method.
Am I way off??
Also, if this app had multiple views, using a tab controller or nav controller, should I handle it in the same wa开发者_StackOverflow社区y (each view for its self) ?
-Nick
viewDidUnload is the right answer in all cases - do not do anything model related in dealloc.
If your view never unloads - you will have to adopt another method - either a timer or another event in your app - say save it every time a cell is edited.
As the iPhone uses a Flash disk, writing to files is quick.
精彩评论