I am trying to save edited Array back to the plist... this code worked fine in ios3.2 in simulator...
Now in ios4.1 (while debugging) when i click the exit button on simulator (and not the Task red button on xcode) it saves to plist and again when i click
the app icon on simulator, it shows the saved changes...........but when i terminate the app by clicking the Task button and restart the app, it doesn't shows the changes....
i have the following code....
Thank you for reading
Now in ios4.1 (while debugging) when i click the exit button on simulator (and not the Task red button on xcode) it saves to plist and again when i click
the app icon on simulator, it shows the saved changes...........but when i terminate the app by clicking the Task button and restart the app, it doesn't shows the changes....
i have the following code....
Code:
-(void)applicationWillTerminate:(UIApplication *)application{
called save function
}
- (void)applicationDidEnterBackground:(UIApplication *)application{
called save function
}
+ (void)save
{
//save contacts list
NSString *path = [[self class] pathForDocumentWithName:@"Contacts.plist"];
NSString *plist = [listOfTempContacts description];
NSError *error = nil;
[plist writeToFile:path atomically:YES encoding:NSUTF8StringEncoding error:&error];
if (error)
{
NSLog(@"Error writing file at path: %@; error was %@", path, error);
}
//save favourite contacts list
path=nil;
plist=nil;
path = [[self class] pathForDocumentWithName:@"FavContacts.plist"];
plist = [listOfTempFavContacts description];
error = nil;
[plist writeToFile:path atomically:YES encoding:NSUTF8StringEncoding error:&error];
if (error)
{
NSLog(@"Error writing file at path: %@; error was %@", path, error);
}
}
Thank you for reading