I use plist to save data as shown below. I need now to delete this data, either all of them or certain record – message in my case – from the plist file , how to do that?
NSMutableData* data = [[NSMutableData alloc] init];
NSKeyedArchiver* archiver = [[NSKeyedArchiver alloc] initForWritingWithMutableData:data];
[archiver encodeObject:self.messages forKey:@"Messages"];
[archiver finishEncoding];
[data writeToFile:[self messagesPath] atomically:YES];
You can just unarchive the same way using an
NSKeyedUnarchiverto get your original data back. Then, assuming it is aNSDictionaryand you make a mutable copy of it, you can remove keys from it just as normal.