Hi Guys
I've been trying to write a simple shopping list program but when i try to write the modified values back to a plist file i only get the original values that were in the file to start with.
My original plist file is one large array (dataArray) of dictionaries with only two fields in each dictionary one bool and one string when you select an item in the tableview the bool value is changed for the single item and when i output the dataArray to the console i can see that the value has been changed, my only problem is that when i try to write dataArray to a file i get the file in the documents directory but all of the bool values are still off.
- (void)viewDidLoad {
//load from plist file
NSString *path = [[NSBundle mainBundle] pathForResource:@"OriginalChecklist" ofType:@"plist"];
self.dataArray = [NSMutableArray arrayWithContentsOfFile:path];
[super viewDidLoad];
}
- (void)viewWillDisappear:(BOOL)animated
{
NSString *documentsDirectory = [@"~/Documents/" stringByExpandingTildeInPath];
NSString *savePath = [documentsDirectory stringByAppendingPathComponent:@"Checklist.plist"];
[dataArray writeToFile:savePath atomically:YES];
NSLog(@"location information %@", savePath);
NSLog(@"dataAray contents %@=", dataArray);
}
And as i said when i output the result of the dataArray to the console i get the following results from the items i checked.
cell = <UITableViewCell: 0x3b143d0; frame = (0 0; 320 44); text = 'Water Bottle'; autoresize = W; layer = <CALayer: 0x3b14650>>;
checked = 1;
text = "Water Bottle";
cell = <UITableViewCell: 0x3b20560; frame = (0 88; 320 44); text = 'GPS'; autoresize = W; layer = <CALayer: 0x3b20610>>;
checked = 1;
text = GPS;
If anyone knows how to save the modified results to the plist file i would much appreciate a little help.
Thanks Brad