I have a UITableView and its a checklist. I can add new cells to the table and you can also delete them. I want to know how to save the tables data when someone leaves/exits a view! Is this possible?Thanks everyone: D
I am using this to save the data:: would this work?
NSArray *sourceData = [[NSUserDefaults standardUserDefaults] arrayForKey:@"funds"];
if (!sourceData)
{
NSString * myFile = [[NSBundle mainBundle]pathForResource:@"cells" ofType:@"plist"];
sourceData = [[NSMutableArray alloc]initWithContentsOfFile:myFile];
}
self.cells = [NSMutableArray array];
for (NSDictionary *immutableCellDictionary in sourceData)
{
[self.cells addObject:[NSMutableDictionary
dictionaryWithDictionary:immutableCellDictionary]];
}
It all depends on what you mean by exiting/leaving a view. One option is using
viewWillDisappear:If this is not fine with your app, please give some more detail about when exactly you want to save the view data.