hi there,
looking for some help.. i have 2 controllers, 1 contains a custom cell table. when user selected a cell, i will be display at the other controller. so far my approach is when at controller 1, if cell selected, save to plist, than at controller 2, load the plist.
my saving and loading code:
NSMutableArray *selectedData;
selectedData = [[NSMutableArray arrayWithCapacity:10]retain]; //10 for 10 cells
NSArray *keys = [NSArray arrayWithObjects:@"one",@"two",@"three",@"four",@"five",@"six",nil];
[selectedData addObject:[NSDictionary dictionaryWithObjects:[NSArray arrayWithObjects:
[NSString stringWithFormat:@"%@",@"test1"],
[NSString stringWithFormat:@"%@",@"test2"],
[NSString stringWithFormat:@"%@",@"test3"],
[NSString stringWithFormat:@"%@",@"test4"],
[NSString stringWithFormat:@"%@",@"test5"],
[NSString stringWithFormat:@"%@",@"test6"],nil]forKeys:keys]];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *path = [documentsDirectory stringByAppendingPathComponent:@"Data.plist"];
[path retain];
[selectedData writeToFile:path atomically:YES];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *path = [documentsDirectory stringByAppendingPathComponent:@"Data.plist"];
self.data = [NSArray arrayWithContentsOfFile:path];
now the problem: i implement the saving to plist code at didSelectRowAtIndexPath: of controller 1, so that when user select a row it will save to plist. but the problem is it only save at the 1st slot/cell. it will keep on over writing. and it will only get display at controller 2 when i exit the app, it doesnt display immediately.
for controller 2 i place the code for loading the plist at viewWillAppear: but it doesnt seems to work
i am missing something..
thx in adv.:)