Writing data to plist

I would like to read data from plist, add some elements and write data to plist (update plist).

I want plist to hold an array of dictionaries, read this array in my application, add dictionaries, and then write the array back to plist.

How it's done? I also do not know where and how to create a layer on the first launch of applications. or should it be put in a bunch from the start?

Another thing I'm not sure about is that there may be syllabic dictionaries, for example. CLLocations as values ​​for keys? Will it be saved correctly or will CLLocation be split into lat and lon values?

thank

+3
source share
1 answer

plist - dictionaryWithContentsOfFile:, , plist :

NSString *filePath = [[NSBundle mainBundle] pathForResource:@"MyPlist" ofType:@"plist"];
NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithContentsOfFile:filePath];

plist :

[dict writeToFile:filePath atomically:YES];

( , , , , "", . NSSearchPathForDirectoriesInDomains)

NSDictionary, NSArray, NSNumber NSString, CLLocation Plist . , Plist, NSKeyedArchiver. NSData , NSCoding (CLLocation).

+6

All Articles