views:

267

answers:

1

Hi

I have a plist with some fixed data, for example

orange

apple

banana

I want to populate a tableview with this data, and the users reorder the table view, and then save the plist with the new order.

Which is the best way to do this? Any tutorial that show how to do?

A lot of thanks

A: 

Assuming you're using a UITableViewDataSource with an array and the list isn't too big, you can use this in -(void)applicationWillTerminate:(UIApplication *)application:

NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setObject:myArray forKey:@"Array"];
[defaults synchronize];

And load it back up in - (void)applicationDidFinishLaunching:(UIApplication *)application:

NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
myArray = [[defaults objectForKey:@"Array"] mutableCopy];
if (myArray == nil) {
    //LOAD FROM PLIST
}

Both of these methods should be in your application delegate.

David Kanarek