рдХреЛрдХреЛ / рдХреЛрдХреЛрдЖрдЯрд╛ рдореЗрдВ .plist рдлрд╝рд╛рдЗрд▓реЛрдВ рдХреЗ рд╕рд╛рде рдХрд╛рдо рдХрд░рдирд╛

рд╕рднреА рдХреЛ рд╢реБрднрдХрд╛рдордирд╛рдПрдБ!

рдЖрдЬ рдореИрдВ рдУрдПрд╕ рдПрдХреНрд╕ рдФрд░ / рдпрд╛ рдЖрдИрдУрдПрд╕ рдореЗрдВ рд╕реЗрдЯрд┐рдВрдЧреНрд╕ рдФрд░ рдЕрдиреНрдп рдкреНрд░реЛрдЧреНрд░рд╛рдо рдбреЗрдЯрд╛ рдХреЛ рдмрдЪрд╛рдиреЗ рдХреЗ рдХреБрдЫ рдкрд╣рд▓реБрдУрдВ рдХреЗ рдмрд╛рд░реЗ рдореЗрдВ рдмрд╛рдд рдХрд░рдирд╛ рдЪрд╛рд╣реВрдВрдЧрд╛ред рд╣рдореЗрд╢рд╛ рдХреА рддрд░рд╣, рд╣рдорд╛рд░реЗ рдкрд╛рд╕ рдХрдИ рд╡рд┐рдХрд▓реНрдк рд╣реИрдВ: рдХреЛрд░ рдбреЗрдЯрд╛, рдирдВрдЧреЗ SQLite, рд╣рдорд╛рд░реЗ рджреНрд╡рд┐рдЖрдзрд╛рд░реА рдкреНрд░рд╛рд░реВрдк, рд╣рдорд╛рд░реЗ рдкрд╛рда рдкреНрд░рд╛рд░реВрдк, NSUserDefaults рдФрд░, рдЬреИрд╕рд╛ рдХрд┐ рдЖрдкрдиреЗ рд╢рд╛рдпрдж рд╕реБрдирд╛ рд╣реИ, PLIST , рдпрд╛рдиреА XML P roperty рд╕реВрдЪреА рдЬреИрд╕реА рдлрд╛рдЗрд▓реЗрдВред

рд╕рдВрдХреНрд╖реЗрдк рдореЗрдВ, рдкреНрд▓рд┐рд╕реНрдЯ рдлрд╛рдЗрд▓реЗрдВ рд╕рд╛рджреЗ XML рдХреА рд╣реИрдВ, рд▓реЗрдХрд┐рди рдХреБрдЫ рдХреИрд╡рд┐рдЯреАрдЬрд╝ рдХреЗ рд╕рд╛рдеред рдЙрджрд╛рд╣рд░рдг рдХреЗ рд▓рд┐рдП, рдЗрд╕рдореЗрдВ рдЯреИрдЧ рдХрд╛ рдХреНрд░рдо рдХреБрдЫ рдирд┐рдпрдореЛрдВ рджреНрд╡рд╛рд░рд╛ рдирд┐рд░реНрдзрд╛рд░рд┐рдд рдХрд┐рдпрд╛ рдЬрд╛рддрд╛ рд╣реИ: рд╡реЗ рдХреБрдВрдЬреА-рдореВрд▓реНрдп рд╡рд╛рд▓реЗ рдЬреЛрдбрд╝реЗ рдореЗрдВ рдЬрд╛рддреЗ рд╣реИрдВ, рд▓реЗрдХрд┐рди рдЯрд╛рдЗрдк рдХреБрдВрдЬреА рдХреЗ рдЯреИрдЧ рдФрд░ рдкреНрд░рдХрд╛рд░ рдХреЗ рдореВрд▓реНрдп рдХреЗ рдЯреИрдЧ рдПрдХ рд╣реА рд╕реНрддрд░ рдкрд░ рд╕реНрдерд┐рдд рд╣реЛрддреЗ рд╣реИрдВред рдПрдХ рд╡рд┐рд╢рд┐рд╖реНрдЯ рдЙрджрд╛рд╣рд░рдг:

<key>identifier</key> <string>j3qq4-h7h2v</string> 

рдкреМрдзреЗ рдореБрдЦреНрдп рдХреЛрдХреЛ рдбреЗрдЯрд╛ рдкреНрд░рдХрд╛рд░реЛрдВ рдХреЛ рд╕реНрдЯреЛрд░ рдХрд░ рд╕рдХрддреЗ рд╣реИрдВ: рдПрдирдПрд╕рдПрд╕рдЯреНрд░рд┐рдВрдЧ, рдПрдирдПрд╕рдПрдирдореНрдмрд░ (рдЗрдВрдЯ, рдлреНрд▓реЛрдЯ, рдмреАрдУрдУрдПрд▓), рдПрдирдПрд╕рдбреА, рдПрдирдПрд╕рдПрд░реЗ, рдПрдирдПрд╕рдПрдбрд░ рдФрд░ рдПрдирдПрд╕рдбрд╛рдЯрд╛ред рдирд┐рдореНрдирд▓рд┐рдЦрд┐рдд рдЯреИрдЧ рдЗрди рдкреНрд░рдХрд╛рд░реЛрдВ рдХреЗ рдЕрдиреБрд░реВрдк рд╣реИрдВ: , , , <true/>, <false/>, , , , . , plist , .

- , , API .

plist' : " ?", " ?", " ?" . , .

, , , . : , . , , . : NSCoding NSData NSKeyedArchiver. NSData . .

. , bplist ( B inary Plist ), . : Xcode , XML , : plutil -convert xml1 MyFile.plist . , plutil JSON, - , .

NSUserDefaults, . , ~/Library/Preferences/com.yourcompany.yourapp.plist (, , , , bplist), . , ? NSPropertyListSerialization , Cocoa.

, ? , NSDictionary NSArray NSData, plist. , , : NSData NSDictionary NSArray.

: ( ) , .

- (IBAction)savePlist:(id)sender { NSMutableDictionary *root = [NSMutableDictionary dictionary]; [root setObject:@YES forKey:@"autosave"]; [root setObject:@"hello" forKey:@"greet-text"]; [root setObject:@"4F4@@" forKey:@"identifier"]; NSMutableArray *elements = [NSMutableArray array]; [elements addObject:@"one"]; [elements addObject:@"two"]; [elements addObject:@"thee"]; [root setObject:elements forKey:@"elements"]; NSMutableArray *subs = [NSMutableArray array]; for (NSInteger i = 0; i < 10; i++) { NSMutableDictionary *dict = [NSMutableDictionary dictionary]; [dict setObject:[NSString stringWithFormat:@"John %ld", i] forKey:@"name"]; [dict setObject:[NSString stringWithFormat:@"Moscow %ld", i] forKey:@"city"]; [dict setObject:[NSNumber numberWithInteger:i] forKey:@"id"]; [subs addObject:dict]; } [root setObject:subs forKey:@"subs"]; NSLog(@"saving data:\n%@", root); NSError *error = nil; NSData *representation = [NSPropertyListSerialization dataWithPropertyList:root format:NSPropertyListXMLFormat_v1_0 options:0 error:&error]; if (!error) { BOOL ok = [representation writeToFile:self.plistFileName atomically:YES]; if (ok) { NSLog(@"ok!"); } else { NSLog(@"error writing to file: %@", self.plistFileName); } } else { NSLog(@"error: %@", error); } }
, , , :

<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>autosave</key> <true/> <key>elements</key> <array> <string>one</string> <string>two</string> <string>thee</string> </array> <key>greet-text</key> <string>hello</string> <key>identifier</key> <string>4F4@@</string> <key>subs</key> <array> <dict> <key>city</key> <string>Moscow 0</string> <key>id</key> <integer>0</integer> <key>name</key> <string>John 0</string> </dict> <dict> <key>city</key> <string>Moscow 1</string> <key>id</key> <integer>1</integer> <key>name</key> <string>John 1</string> </dict> <!-- --> </array> </dict> </plist>
, ? ! XML . :

{ autosave = 1; elements = ( one, two, thee ); "greet-text" = hello; identifier = "4F4@@"; subs = ( { city = "Moscow 0"; id = 0; name = "John 0"; }, { city = "Moscow 1"; id = 1; name = "John 1"; } ); }
.

:

- (IBAction)loadPlist:(id)sender { NSData *plistData = [NSData dataWithContentsOfFile:self.plistFileName]; if (!plistData) { NSLog(@"error reading from file: %@", self.plistFileName); return; } NSPropertyListFormat format; NSError *error = nil; id plist = [NSPropertyListSerialization propertyListWithData:plistData options:NSPropertyListMutableContainersAndLeaves format:&format error:&error]; if (!error) { NSMutableDictionary *root = plist; NSLog(@"loaded data:\n%@", root); } else { NSLog(@"error: %@", error); } }
? ! JSON-, ! , , : NSDictionary . .

, "mutable" , NSPropertyListMutableContainersAndLeaves . NSPropertyListImmutable , NSMutableDictionary, NSDictionary, .

, PLIST Cocoa. , , .

!

UPD: mejedi , plain-XML .

XML ┬л ┬╗, ( , ┬лhello world┬╗ , ).

, тАФ 10.6 , , 10.8 , - ( __CFBinaryPlistWrite).
, , , <true/>, <false/>, , , , . , plist , .

- , , API .

plist' : " ?", " ?", " ?" . , .

, , , . : , . , , . : NSCoding NSData NSKeyedArchiver. NSData . .

. , bplist ( B inary Plist ), . : Xcode , XML , : plutil -convert xml1 MyFile.plist
. , plutil JSON, - , .

NSUserDefaults, . , ~/Library/Preferences/com.yourcompany.yourapp.plist (, , , , bplist), . , ? NSPropertyListSerialization , Cocoa.

, ? , NSDictionary NSArray NSData, plist. , , : NSData NSDictionary NSArray.

: ( ) , .

- (IBAction)savePlist:(id)sender { NSMutableDictionary *root = [NSMutableDictionary dictionary]; [root setObject:@YES forKey:@"autosave"]; [root setObject:@"hello" forKey:@"greet-text"]; [root setObject:@"4F4@@" forKey:@"identifier"]; NSMutableArray *elements = [NSMutableArray array]; [elements addObject:@"one"]; [elements addObject:@"two"]; [elements addObject:@"thee"]; [root setObject:elements forKey:@"elements"]; NSMutableArray *subs = [NSMutableArray array]; for (NSInteger i = 0; i < 10; i++) { NSMutableDictionary *dict = [NSMutableDictionary dictionary]; [dict setObject:[NSString stringWithFormat:@"John %ld", i] forKey:@"name"]; [dict setObject:[NSString stringWithFormat:@"Moscow %ld", i] forKey:@"city"]; [dict setObject:[NSNumber numberWithInteger:i] forKey:@"id"]; [subs addObject:dict]; } [root setObject:subs forKey:@"subs"]; NSLog(@"saving data:\n%@", root); NSError *error = nil; NSData *representation = [NSPropertyListSerialization dataWithPropertyList:root format:NSPropertyListXMLFormat_v1_0 options:0 error:&error]; if (!error) { BOOL ok = [representation writeToFile:self.plistFileName atomically:YES]; if (ok) { NSLog(@"ok!"); } else { NSLog(@"error writing to file: %@", self.plistFileName); } } else { NSLog(@"error: %@", error); } }
, , , :

<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>autosave</key> <true/> <key>elements</key> <array> <string>one</string> <string>two</string> <string>thee</string> </array> <key>greet-text</key> <string>hello</string> <key>identifier</key> <string>4F4@@</string> <key>subs</key> <array> <dict> <key>city</key> <string>Moscow 0</string> <key>id</key> <integer>0</integer> <key>name</key> <string>John 0</string> </dict> <dict> <key>city</key> <string>Moscow 1</string> <key>id</key> <integer>1</integer> <key>name</key> <string>John 1</string> </dict> <!-- --> </array> </dict> </plist>
, ? ! XML . :

{ autosave = 1; elements = ( one, two, thee ); "greet-text" = hello; identifier = "4F4@@"; subs = ( { city = "Moscow 0"; id = 0; name = "John 0"; }, { city = "Moscow 1"; id = 1; name = "John 1"; } ); }
.

:

- (IBAction)loadPlist:(id)sender { NSData *plistData = [NSData dataWithContentsOfFile:self.plistFileName]; if (!plistData) { NSLog(@"error reading from file: %@", self.plistFileName); return; } NSPropertyListFormat format; NSError *error = nil; id plist = [NSPropertyListSerialization propertyListWithData:plistData options:NSPropertyListMutableContainersAndLeaves format:&format error:&error]; if (!error) { NSMutableDictionary *root = plist; NSLog(@"loaded data:\n%@", root); } else { NSLog(@"error: %@", error); } }
? ! JSON-, ! , , : NSDictionary . .

, "mutable" , NSPropertyListMutableContainersAndLeaves . NSPropertyListImmutable , NSMutableDictionary, NSDictionary, .

, PLIST Cocoa. , , .

!

UPD: mejedi , plain-XML .

XML ┬л ┬╗, ( , ┬лhello world┬╗ , ).

, тАФ 10.6 , , 10.8 , - ( __CFBinaryPlistWrite).
 , , , <true/>, <false/>, , , , . , plist    ,       . 

- , , API .

plist' : " ?", " ?", " ?" . , .

, , , . : , . , , . : NSCoding NSData NSKeyedArchiver. NSData . .

. , bplist ( B inary Plist ), . : Xcode , XML , : plutil -convert xml1 MyFile.plist
. , plutil JSON, - , .

NSUserDefaults, . , ~/Library/Preferences/com.yourcompany.yourapp.plist (, , , , bplist), . , ? NSPropertyListSerialization , Cocoa.

, ? , NSDictionary NSArray NSData, plist. , , : NSData NSDictionary NSArray.

: ( ) , .

- (IBAction)savePlist:(id)sender { NSMutableDictionary *root = [NSMutableDictionary dictionary]; [root setObject:@YES forKey:@"autosave"]; [root setObject:@"hello" forKey:@"greet-text"]; [root setObject:@"4F4@@" forKey:@"identifier"]; NSMutableArray *elements = [NSMutableArray array]; [elements addObject:@"one"]; [elements addObject:@"two"]; [elements addObject:@"thee"]; [root setObject:elements forKey:@"elements"]; NSMutableArray *subs = [NSMutableArray array]; for (NSInteger i = 0; i < 10; i++) { NSMutableDictionary *dict = [NSMutableDictionary dictionary]; [dict setObject:[NSString stringWithFormat:@"John %ld", i] forKey:@"name"]; [dict setObject:[NSString stringWithFormat:@"Moscow %ld", i] forKey:@"city"]; [dict setObject:[NSNumber numberWithInteger:i] forKey:@"id"]; [subs addObject:dict]; } [root setObject:subs forKey:@"subs"]; NSLog(@"saving data:\n%@", root); NSError *error = nil; NSData *representation = [NSPropertyListSerialization dataWithPropertyList:root format:NSPropertyListXMLFormat_v1_0 options:0 error:&error]; if (!error) { BOOL ok = [representation writeToFile:self.plistFileName atomically:YES]; if (ok) { NSLog(@"ok!"); } else { NSLog(@"error writing to file: %@", self.plistFileName); } } else { NSLog(@"error: %@", error); } }
, , , :

<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>autosave</key> <true/> <key>elements</key> <array> <string>one</string> <string>two</string> <string>thee</string> </array> <key>greet-text</key> <string>hello</string> <key>identifier</key> <string>4F4@@</string> <key>subs</key> <array> <dict> <key>city</key> <string>Moscow 0</string> <key>id</key> <integer>0</integer> <key>name</key> <string>John 0</string> </dict> <dict> <key>city</key> <string>Moscow 1</string> <key>id</key> <integer>1</integer> <key>name</key> <string>John 1</string> </dict> <!-- --> </array> </dict> </plist>
, ? ! XML . :

{ autosave = 1; elements = ( one, two, thee ); "greet-text" = hello; identifier = "4F4@@"; subs = ( { city = "Moscow 0"; id = 0; name = "John 0"; }, { city = "Moscow 1"; id = 1; name = "John 1"; } ); }
.

:

- (IBAction)loadPlist:(id)sender { NSData *plistData = [NSData dataWithContentsOfFile:self.plistFileName]; if (!plistData) { NSLog(@"error reading from file: %@", self.plistFileName); return; } NSPropertyListFormat format; NSError *error = nil; id plist = [NSPropertyListSerialization propertyListWithData:plistData options:NSPropertyListMutableContainersAndLeaves format:&format error:&error]; if (!error) { NSMutableDictionary *root = plist; NSLog(@"loaded data:\n%@", root); } else { NSLog(@"error: %@", error); } }
? ! JSON-, ! , , : NSDictionary . .

, "mutable" , NSPropertyListMutableContainersAndLeaves . NSPropertyListImmutable , NSMutableDictionary, NSDictionary, .

, PLIST Cocoa. , , .

!

UPD: mejedi , plain-XML .

XML ┬л ┬╗, ( , ┬лhello world┬╗ , ).

, тАФ 10.6 , , 10.8 , - ( __CFBinaryPlistWrite).
, , , <true/>, <false/>, , , , . , plist , .

- , , API .

plist' : " ?", " ?", " ?" . , .

, , , . : , . , , . : NSCoding NSData NSKeyedArchiver. NSData . .

. , bplist ( B inary Plist ), . : Xcode , XML , : plutil -convert xml1 MyFile.plist
. , plutil JSON, - , .

NSUserDefaults, . , ~/Library/Preferences/com.yourcompany.yourapp.plist (, , , , bplist), . , ? NSPropertyListSerialization , Cocoa.

, ? , NSDictionary NSArray NSData, plist. , , : NSData NSDictionary NSArray.

: ( ) , .

- (IBAction)savePlist:(id)sender { NSMutableDictionary *root = [NSMutableDictionary dictionary]; [root setObject:@YES forKey:@"autosave"]; [root setObject:@"hello" forKey:@"greet-text"]; [root setObject:@"4F4@@" forKey:@"identifier"]; NSMutableArray *elements = [NSMutableArray array]; [elements addObject:@"one"]; [elements addObject:@"two"]; [elements addObject:@"thee"]; [root setObject:elements forKey:@"elements"]; NSMutableArray *subs = [NSMutableArray array]; for (NSInteger i = 0; i < 10; i++) { NSMutableDictionary *dict = [NSMutableDictionary dictionary]; [dict setObject:[NSString stringWithFormat:@"John %ld", i] forKey:@"name"]; [dict setObject:[NSString stringWithFormat:@"Moscow %ld", i] forKey:@"city"]; [dict setObject:[NSNumber numberWithInteger:i] forKey:@"id"]; [subs addObject:dict]; } [root setObject:subs forKey:@"subs"]; NSLog(@"saving data:\n%@", root); NSError *error = nil; NSData *representation = [NSPropertyListSerialization dataWithPropertyList:root format:NSPropertyListXMLFormat_v1_0 options:0 error:&error]; if (!error) { BOOL ok = [representation writeToFile:self.plistFileName atomically:YES]; if (ok) { NSLog(@"ok!"); } else { NSLog(@"error writing to file: %@", self.plistFileName); } } else { NSLog(@"error: %@", error); } }
, , , :

<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>autosave</key> <true/> <key>elements</key> <array> <string>one</string> <string>two</string> <string>thee</string> </array> <key>greet-text</key> <string>hello</string> <key>identifier</key> <string>4F4@@</string> <key>subs</key> <array> <dict> <key>city</key> <string>Moscow 0</string> <key>id</key> <integer>0</integer> <key>name</key> <string>John 0</string> </dict> <dict> <key>city</key> <string>Moscow 1</string> <key>id</key> <integer>1</integer> <key>name</key> <string>John 1</string> </dict> <!-- --> </array> </dict> </plist>
, ? ! XML . :

{ autosave = 1; elements = ( one, two, thee ); "greet-text" = hello; identifier = "4F4@@"; subs = ( { city = "Moscow 0"; id = 0; name = "John 0"; }, { city = "Moscow 1"; id = 1; name = "John 1"; } ); }
.

:

- (IBAction)loadPlist:(id)sender { NSData *plistData = [NSData dataWithContentsOfFile:self.plistFileName]; if (!plistData) { NSLog(@"error reading from file: %@", self.plistFileName); return; } NSPropertyListFormat format; NSError *error = nil; id plist = [NSPropertyListSerialization propertyListWithData:plistData options:NSPropertyListMutableContainersAndLeaves format:&format error:&error]; if (!error) { NSMutableDictionary *root = plist; NSLog(@"loaded data:\n%@", root); } else { NSLog(@"error: %@", error); } }
? ! JSON-, ! , , : NSDictionary . .

, "mutable" , NSPropertyListMutableContainersAndLeaves . NSPropertyListImmutable , NSMutableDictionary, NSDictionary, .

, PLIST Cocoa. , , .

!

UPD: mejedi , plain-XML .

XML ┬л ┬╗, ( , ┬лhello world┬╗ , ).

, тАФ 10.6 , , 10.8 , - ( __CFBinaryPlistWrite).
 , , , <true/>, <false/>, , , , . , plist    ,       . 

- , , API .

plist' : " ?", " ?", " ?" . , .

, , , . : , . , , . : NSCoding NSData NSKeyedArchiver. NSData . .

. , bplist ( B inary Plist ), . : Xcode , XML , : plutil -convert xml1 MyFile.plist
. , plutil JSON, - , .

NSUserDefaults, . , ~/Library/Preferences/com.yourcompany.yourapp.plist (, , , , bplist), . , ? NSPropertyListSerialization , Cocoa.

, ? , NSDictionary NSArray NSData, plist. , , : NSData NSDictionary NSArray.

: ( ) , .

- (IBAction)savePlist:(id)sender { NSMutableDictionary *root = [NSMutableDictionary dictionary]; [root setObject:@YES forKey:@"autosave"]; [root setObject:@"hello" forKey:@"greet-text"]; [root setObject:@"4F4@@" forKey:@"identifier"]; NSMutableArray *elements = [NSMutableArray array]; [elements addObject:@"one"]; [elements addObject:@"two"]; [elements addObject:@"thee"]; [root setObject:elements forKey:@"elements"]; NSMutableArray *subs = [NSMutableArray array]; for (NSInteger i = 0; i < 10; i++) { NSMutableDictionary *dict = [NSMutableDictionary dictionary]; [dict setObject:[NSString stringWithFormat:@"John %ld", i] forKey:@"name"]; [dict setObject:[NSString stringWithFormat:@"Moscow %ld", i] forKey:@"city"]; [dict setObject:[NSNumber numberWithInteger:i] forKey:@"id"]; [subs addObject:dict]; } [root setObject:subs forKey:@"subs"]; NSLog(@"saving data:\n%@", root); NSError *error = nil; NSData *representation = [NSPropertyListSerialization dataWithPropertyList:root format:NSPropertyListXMLFormat_v1_0 options:0 error:&error]; if (!error) { BOOL ok = [representation writeToFile:self.plistFileName atomically:YES]; if (ok) { NSLog(@"ok!"); } else { NSLog(@"error writing to file: %@", self.plistFileName); } } else { NSLog(@"error: %@", error); } }
, , , :

<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>autosave</key> <true/> <key>elements</key> <array> <string>one</string> <string>two</string> <string>thee</string> </array> <key>greet-text</key> <string>hello</string> <key>identifier</key> <string>4F4@@</string> <key>subs</key> <array> <dict> <key>city</key> <string>Moscow 0</string> <key>id</key> <integer>0</integer> <key>name</key> <string>John 0</string> </dict> <dict> <key>city</key> <string>Moscow 1</string> <key>id</key> <integer>1</integer> <key>name</key> <string>John 1</string> </dict> <!-- --> </array> </dict> </plist>
, ? ! XML . :

{ autosave = 1; elements = ( one, two, thee ); "greet-text" = hello; identifier = "4F4@@"; subs = ( { city = "Moscow 0"; id = 0; name = "John 0"; }, { city = "Moscow 1"; id = 1; name = "John 1"; } ); }
.

:

- (IBAction)loadPlist:(id)sender { NSData *plistData = [NSData dataWithContentsOfFile:self.plistFileName]; if (!plistData) { NSLog(@"error reading from file: %@", self.plistFileName); return; } NSPropertyListFormat format; NSError *error = nil; id plist = [NSPropertyListSerialization propertyListWithData:plistData options:NSPropertyListMutableContainersAndLeaves format:&format error:&error]; if (!error) { NSMutableDictionary *root = plist; NSLog(@"loaded data:\n%@", root); } else { NSLog(@"error: %@", error); } }
? ! JSON-, ! , , : NSDictionary . .

, "mutable" , NSPropertyListMutableContainersAndLeaves . NSPropertyListImmutable , NSMutableDictionary, NSDictionary, .

, PLIST Cocoa. , , .

!

UPD: mejedi , plain-XML .

XML ┬л ┬╗, ( , ┬лhello world┬╗ , ).

, тАФ 10.6 , , 10.8 , - ( __CFBinaryPlistWrite).
, , , <true/>, <false/>, , , , . , plist , .

- , , API .

plist' : " ?", " ?", " ?" . , .

, , , . : , . , , . : NSCoding NSData NSKeyedArchiver. NSData . .

. , bplist ( B inary Plist ), . : Xcode , XML , : plutil -convert xml1 MyFile.plist
. , plutil JSON, - , .

NSUserDefaults, . , ~/Library/Preferences/com.yourcompany.yourapp.plist (, , , , bplist), . , ? NSPropertyListSerialization , Cocoa.

, ? , NSDictionary NSArray NSData, plist. , , : NSData NSDictionary NSArray.

: ( ) , .

- (IBAction)savePlist:(id)sender { NSMutableDictionary *root = [NSMutableDictionary dictionary]; [root setObject:@YES forKey:@"autosave"]; [root setObject:@"hello" forKey:@"greet-text"]; [root setObject:@"4F4@@" forKey:@"identifier"]; NSMutableArray *elements = [NSMutableArray array]; [elements addObject:@"one"]; [elements addObject:@"two"]; [elements addObject:@"thee"]; [root setObject:elements forKey:@"elements"]; NSMutableArray *subs = [NSMutableArray array]; for (NSInteger i = 0; i < 10; i++) { NSMutableDictionary *dict = [NSMutableDictionary dictionary]; [dict setObject:[NSString stringWithFormat:@"John %ld", i] forKey:@"name"]; [dict setObject:[NSString stringWithFormat:@"Moscow %ld", i] forKey:@"city"]; [dict setObject:[NSNumber numberWithInteger:i] forKey:@"id"]; [subs addObject:dict]; } [root setObject:subs forKey:@"subs"]; NSLog(@"saving data:\n%@", root); NSError *error = nil; NSData *representation = [NSPropertyListSerialization dataWithPropertyList:root format:NSPropertyListXMLFormat_v1_0 options:0 error:&error]; if (!error) { BOOL ok = [representation writeToFile:self.plistFileName atomically:YES]; if (ok) { NSLog(@"ok!"); } else { NSLog(@"error writing to file: %@", self.plistFileName); } } else { NSLog(@"error: %@", error); } }
, , , :

<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>autosave</key> <true/> <key>elements</key> <array> <string>one</string> <string>two</string> <string>thee</string> </array> <key>greet-text</key> <string>hello</string> <key>identifier</key> <string>4F4@@</string> <key>subs</key> <array> <dict> <key>city</key> <string>Moscow 0</string> <key>id</key> <integer>0</integer> <key>name</key> <string>John 0</string> </dict> <dict> <key>city</key> <string>Moscow 1</string> <key>id</key> <integer>1</integer> <key>name</key> <string>John 1</string> </dict> <!-- --> </array> </dict> </plist>
, ? ! XML . :

{ autosave = 1; elements = ( one, two, thee ); "greet-text" = hello; identifier = "4F4@@"; subs = ( { city = "Moscow 0"; id = 0; name = "John 0"; }, { city = "Moscow 1"; id = 1; name = "John 1"; } ); }
.

:

- (IBAction)loadPlist:(id)sender { NSData *plistData = [NSData dataWithContentsOfFile:self.plistFileName]; if (!plistData) { NSLog(@"error reading from file: %@", self.plistFileName); return; } NSPropertyListFormat format; NSError *error = nil; id plist = [NSPropertyListSerialization propertyListWithData:plistData options:NSPropertyListMutableContainersAndLeaves format:&format error:&error]; if (!error) { NSMutableDictionary *root = plist; NSLog(@"loaded data:\n%@", root); } else { NSLog(@"error: %@", error); } }
? ! JSON-, ! , , : NSDictionary . .

, "mutable" , NSPropertyListMutableContainersAndLeaves . NSPropertyListImmutable , NSMutableDictionary, NSDictionary, .

, PLIST Cocoa. , , .

!

UPD: mejedi , plain-XML .

XML ┬л ┬╗, ( , ┬лhello world┬╗ , ).

, тАФ 10.6 , , 10.8 , - ( __CFBinaryPlistWrite).
 , , , <true/>, <false/>, , , , . , plist    ,       . 

- , , API .

plist' : " ?", " ?", " ?" . , .

, , , . : , . , , . : NSCoding NSData NSKeyedArchiver. NSData . .

. , bplist ( B inary Plist ), . : Xcode , XML , : plutil -convert xml1 MyFile.plist
. , plutil JSON, - , .

NSUserDefaults, . , ~/Library/Preferences/com.yourcompany.yourapp.plist (, , , , bplist), . , ? NSPropertyListSerialization , Cocoa.

, ? , NSDictionary NSArray NSData, plist. , , : NSData NSDictionary NSArray.

: ( ) , .

- (IBAction)savePlist:(id)sender { NSMutableDictionary *root = [NSMutableDictionary dictionary]; [root setObject:@YES forKey:@"autosave"]; [root setObject:@"hello" forKey:@"greet-text"]; [root setObject:@"4F4@@" forKey:@"identifier"]; NSMutableArray *elements = [NSMutableArray array]; [elements addObject:@"one"]; [elements addObject:@"two"]; [elements addObject:@"thee"]; [root setObject:elements forKey:@"elements"]; NSMutableArray *subs = [NSMutableArray array]; for (NSInteger i = 0; i < 10; i++) { NSMutableDictionary *dict = [NSMutableDictionary dictionary]; [dict setObject:[NSString stringWithFormat:@"John %ld", i] forKey:@"name"]; [dict setObject:[NSString stringWithFormat:@"Moscow %ld", i] forKey:@"city"]; [dict setObject:[NSNumber numberWithInteger:i] forKey:@"id"]; [subs addObject:dict]; } [root setObject:subs forKey:@"subs"]; NSLog(@"saving data:\n%@", root); NSError *error = nil; NSData *representation = [NSPropertyListSerialization dataWithPropertyList:root format:NSPropertyListXMLFormat_v1_0 options:0 error:&error]; if (!error) { BOOL ok = [representation writeToFile:self.plistFileName atomically:YES]; if (ok) { NSLog(@"ok!"); } else { NSLog(@"error writing to file: %@", self.plistFileName); } } else { NSLog(@"error: %@", error); } }
, , , :

<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>autosave</key> <true/> <key>elements</key> <array> <string>one</string> <string>two</string> <string>thee</string> </array> <key>greet-text</key> <string>hello</string> <key>identifier</key> <string>4F4@@</string> <key>subs</key> <array> <dict> <key>city</key> <string>Moscow 0</string> <key>id</key> <integer>0</integer> <key>name</key> <string>John 0</string> </dict> <dict> <key>city</key> <string>Moscow 1</string> <key>id</key> <integer>1</integer> <key>name</key> <string>John 1</string> </dict> <!-- --> </array> </dict> </plist>
, ? ! XML . :

{ autosave = 1; elements = ( one, two, thee ); "greet-text" = hello; identifier = "4F4@@"; subs = ( { city = "Moscow 0"; id = 0; name = "John 0"; }, { city = "Moscow 1"; id = 1; name = "John 1"; } ); }
.

:

- (IBAction)loadPlist:(id)sender { NSData *plistData = [NSData dataWithContentsOfFile:self.plistFileName]; if (!plistData) { NSLog(@"error reading from file: %@", self.plistFileName); return; } NSPropertyListFormat format; NSError *error = nil; id plist = [NSPropertyListSerialization propertyListWithData:plistData options:NSPropertyListMutableContainersAndLeaves format:&format error:&error]; if (!error) { NSMutableDictionary *root = plist; NSLog(@"loaded data:\n%@", root); } else { NSLog(@"error: %@", error); } }
? ! JSON-, ! , , : NSDictionary . .

, "mutable" , NSPropertyListMutableContainersAndLeaves . NSPropertyListImmutable , NSMutableDictionary, NSDictionary, .

, PLIST Cocoa. , , .

!

UPD: mejedi , plain-XML .

XML ┬л ┬╗, ( , ┬лhello world┬╗ , ).

, тАФ 10.6 , , 10.8 , - ( __CFBinaryPlistWrite).
, , , <true/>, <false/>, , , , . , plist , .

- , , API .

plist' : " ?", " ?", " ?" . , .

, , , . : , . , , . : NSCoding NSData NSKeyedArchiver. NSData . .

. , bplist ( B inary Plist ), . : Xcode , XML , : plutil -convert xml1 MyFile.plist
. , plutil JSON, - , .

NSUserDefaults, . , ~/Library/Preferences/com.yourcompany.yourapp.plist (, , , , bplist), . , ? NSPropertyListSerialization , Cocoa.

, ? , NSDictionary NSArray NSData, plist. , , : NSData NSDictionary NSArray.

: ( ) , .

- (IBAction)savePlist:(id)sender { NSMutableDictionary *root = [NSMutableDictionary dictionary]; [root setObject:@YES forKey:@"autosave"]; [root setObject:@"hello" forKey:@"greet-text"]; [root setObject:@"4F4@@" forKey:@"identifier"]; NSMutableArray *elements = [NSMutableArray array]; [elements addObject:@"one"]; [elements addObject:@"two"]; [elements addObject:@"thee"]; [root setObject:elements forKey:@"elements"]; NSMutableArray *subs = [NSMutableArray array]; for (NSInteger i = 0; i < 10; i++) { NSMutableDictionary *dict = [NSMutableDictionary dictionary]; [dict setObject:[NSString stringWithFormat:@"John %ld", i] forKey:@"name"]; [dict setObject:[NSString stringWithFormat:@"Moscow %ld", i] forKey:@"city"]; [dict setObject:[NSNumber numberWithInteger:i] forKey:@"id"]; [subs addObject:dict]; } [root setObject:subs forKey:@"subs"]; NSLog(@"saving data:\n%@", root); NSError *error = nil; NSData *representation = [NSPropertyListSerialization dataWithPropertyList:root format:NSPropertyListXMLFormat_v1_0 options:0 error:&error]; if (!error) { BOOL ok = [representation writeToFile:self.plistFileName atomically:YES]; if (ok) { NSLog(@"ok!"); } else { NSLog(@"error writing to file: %@", self.plistFileName); } } else { NSLog(@"error: %@", error); } }
, , , :

<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>autosave</key> <true/> <key>elements</key> <array> <string>one</string> <string>two</string> <string>thee</string> </array> <key>greet-text</key> <string>hello</string> <key>identifier</key> <string>4F4@@</string> <key>subs</key> <array> <dict> <key>city</key> <string>Moscow 0</string> <key>id</key> <integer>0</integer> <key>name</key> <string>John 0</string> </dict> <dict> <key>city</key> <string>Moscow 1</string> <key>id</key> <integer>1</integer> <key>name</key> <string>John 1</string> </dict> <!-- --> </array> </dict> </plist>
, ? ! XML . :

{ autosave = 1; elements = ( one, two, thee ); "greet-text" = hello; identifier = "4F4@@"; subs = ( { city = "Moscow 0"; id = 0; name = "John 0"; }, { city = "Moscow 1"; id = 1; name = "John 1"; } ); }
.

:

- (IBAction)loadPlist:(id)sender { NSData *plistData = [NSData dataWithContentsOfFile:self.plistFileName]; if (!plistData) { NSLog(@"error reading from file: %@", self.plistFileName); return; } NSPropertyListFormat format; NSError *error = nil; id plist = [NSPropertyListSerialization propertyListWithData:plistData options:NSPropertyListMutableContainersAndLeaves format:&format error:&error]; if (!error) { NSMutableDictionary *root = plist; NSLog(@"loaded data:\n%@", root); } else { NSLog(@"error: %@", error); } }
? ! JSON-, ! , , : NSDictionary . .

, "mutable" , NSPropertyListMutableContainersAndLeaves . NSPropertyListImmutable , NSMutableDictionary, NSDictionary, .

, PLIST Cocoa. , , .

!

UPD: mejedi , plain-XML .

XML ┬л ┬╗, ( , ┬лhello world┬╗ , ).

, тАФ 10.6 , , 10.8 , - ( __CFBinaryPlistWrite).
 , , , <true/>, <false/>, , , , . , plist    ,       . 

- , , API .

plist' : " ?", " ?", " ?" . , .

, , , . : , . , , . : NSCoding NSData NSKeyedArchiver. NSData . .

. , bplist ( B inary Plist ), . : Xcode , XML , : plutil -convert xml1 MyFile.plist
. , plutil JSON, - , .

NSUserDefaults, . , ~/Library/Preferences/com.yourcompany.yourapp.plist (, , , , bplist), . , ? NSPropertyListSerialization , Cocoa.

, ? , NSDictionary NSArray NSData, plist. , , : NSData NSDictionary NSArray.

: ( ) , .

- (IBAction)savePlist:(id)sender { NSMutableDictionary *root = [NSMutableDictionary dictionary]; [root setObject:@YES forKey:@"autosave"]; [root setObject:@"hello" forKey:@"greet-text"]; [root setObject:@"4F4@@" forKey:@"identifier"]; NSMutableArray *elements = [NSMutableArray array]; [elements addObject:@"one"]; [elements addObject:@"two"]; [elements addObject:@"thee"]; [root setObject:elements forKey:@"elements"]; NSMutableArray *subs = [NSMutableArray array]; for (NSInteger i = 0; i < 10; i++) { NSMutableDictionary *dict = [NSMutableDictionary dictionary]; [dict setObject:[NSString stringWithFormat:@"John %ld", i] forKey:@"name"]; [dict setObject:[NSString stringWithFormat:@"Moscow %ld", i] forKey:@"city"]; [dict setObject:[NSNumber numberWithInteger:i] forKey:@"id"]; [subs addObject:dict]; } [root setObject:subs forKey:@"subs"]; NSLog(@"saving data:\n%@", root); NSError *error = nil; NSData *representation = [NSPropertyListSerialization dataWithPropertyList:root format:NSPropertyListXMLFormat_v1_0 options:0 error:&error]; if (!error) { BOOL ok = [representation writeToFile:self.plistFileName atomically:YES]; if (ok) { NSLog(@"ok!"); } else { NSLog(@"error writing to file: %@", self.plistFileName); } } else { NSLog(@"error: %@", error); } }
, , , :

<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>autosave</key> <true/> <key>elements</key> <array> <string>one</string> <string>two</string> <string>thee</string> </array> <key>greet-text</key> <string>hello</string> <key>identifier</key> <string>4F4@@</string> <key>subs</key> <array> <dict> <key>city</key> <string>Moscow 0</string> <key>id</key> <integer>0</integer> <key>name</key> <string>John 0</string> </dict> <dict> <key>city</key> <string>Moscow 1</string> <key>id</key> <integer>1</integer> <key>name</key> <string>John 1</string> </dict> <!-- --> </array> </dict> </plist>
, ? ! XML . :

{ autosave = 1; elements = ( one, two, thee ); "greet-text" = hello; identifier = "4F4@@"; subs = ( { city = "Moscow 0"; id = 0; name = "John 0"; }, { city = "Moscow 1"; id = 1; name = "John 1"; } ); }
.

:

- (IBAction)loadPlist:(id)sender { NSData *plistData = [NSData dataWithContentsOfFile:self.plistFileName]; if (!plistData) { NSLog(@"error reading from file: %@", self.plistFileName); return; } NSPropertyListFormat format; NSError *error = nil; id plist = [NSPropertyListSerialization propertyListWithData:plistData options:NSPropertyListMutableContainersAndLeaves format:&format error:&error]; if (!error) { NSMutableDictionary *root = plist; NSLog(@"loaded data:\n%@", root); } else { NSLog(@"error: %@", error); } }
? ! JSON-, ! , , : NSDictionary . .

, "mutable" , NSPropertyListMutableContainersAndLeaves . NSPropertyListImmutable , NSMutableDictionary, NSDictionary, .

, PLIST Cocoa. , , .

!

UPD: mejedi , plain-XML .

XML ┬л ┬╗, ( , ┬лhello world┬╗ , ).

, тАФ 10.6 , , 10.8 , - ( __CFBinaryPlistWrite).
, , , <true/>, <false/>, , , , . , plist , .

- , , API .

plist' : " ?", " ?", " ?" . , .

, , , . : , . , , . : NSCoding NSData NSKeyedArchiver. NSData . .

. , bplist ( B inary Plist ), . : Xcode , XML , : plutil -convert xml1 MyFile.plist
. , plutil JSON, - , .

NSUserDefaults, . , ~/Library/Preferences/com.yourcompany.yourapp.plist (, , , , bplist), . , ? NSPropertyListSerialization , Cocoa.

, ? , NSDictionary NSArray NSData, plist. , , : NSData NSDictionary NSArray.

: ( ) , .

- (IBAction)savePlist:(id)sender { NSMutableDictionary *root = [NSMutableDictionary dictionary]; [root setObject:@YES forKey:@"autosave"]; [root setObject:@"hello" forKey:@"greet-text"]; [root setObject:@"4F4@@" forKey:@"identifier"]; NSMutableArray *elements = [NSMutableArray array]; [elements addObject:@"one"]; [elements addObject:@"two"]; [elements addObject:@"thee"]; [root setObject:elements forKey:@"elements"]; NSMutableArray *subs = [NSMutableArray array]; for (NSInteger i = 0; i < 10; i++) { NSMutableDictionary *dict = [NSMutableDictionary dictionary]; [dict setObject:[NSString stringWithFormat:@"John %ld", i] forKey:@"name"]; [dict setObject:[NSString stringWithFormat:@"Moscow %ld", i] forKey:@"city"]; [dict setObject:[NSNumber numberWithInteger:i] forKey:@"id"]; [subs addObject:dict]; } [root setObject:subs forKey:@"subs"]; NSLog(@"saving data:\n%@", root); NSError *error = nil; NSData *representation = [NSPropertyListSerialization dataWithPropertyList:root format:NSPropertyListXMLFormat_v1_0 options:0 error:&error]; if (!error) { BOOL ok = [representation writeToFile:self.plistFileName atomically:YES]; if (ok) { NSLog(@"ok!"); } else { NSLog(@"error writing to file: %@", self.plistFileName); } } else { NSLog(@"error: %@", error); } }
, , , :

<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>autosave</key> <true/> <key>elements</key> <array> <string>one</string> <string>two</string> <string>thee</string> </array> <key>greet-text</key> <string>hello</string> <key>identifier</key> <string>4F4@@</string> <key>subs</key> <array> <dict> <key>city</key> <string>Moscow 0</string> <key>id</key> <integer>0</integer> <key>name</key> <string>John 0</string> </dict> <dict> <key>city</key> <string>Moscow 1</string> <key>id</key> <integer>1</integer> <key>name</key> <string>John 1</string> </dict> <!-- --> </array> </dict> </plist>
, ? ! XML . :

{ autosave = 1; elements = ( one, two, thee ); "greet-text" = hello; identifier = "4F4@@"; subs = ( { city = "Moscow 0"; id = 0; name = "John 0"; }, { city = "Moscow 1"; id = 1; name = "John 1"; } ); }
.

:

- (IBAction)loadPlist:(id)sender { NSData *plistData = [NSData dataWithContentsOfFile:self.plistFileName]; if (!plistData) { NSLog(@"error reading from file: %@", self.plistFileName); return; } NSPropertyListFormat format; NSError *error = nil; id plist = [NSPropertyListSerialization propertyListWithData:plistData options:NSPropertyListMutableContainersAndLeaves format:&format error:&error]; if (!error) { NSMutableDictionary *root = plist; NSLog(@"loaded data:\n%@", root); } else { NSLog(@"error: %@", error); } }
? ! JSON-, ! , , : NSDictionary . .

, "mutable" , NSPropertyListMutableContainersAndLeaves . NSPropertyListImmutable , NSMutableDictionary, NSDictionary, .

, PLIST Cocoa. , , .

!

UPD: mejedi , plain-XML .

XML ┬л ┬╗, ( , ┬лhello world┬╗ , ).

, тАФ 10.6 , , 10.8 , - ( __CFBinaryPlistWrite).
, , , <true/>, <false/>, , , , . , plist , .

- , , API .

plist' : " ?", " ?", " ?" . , .

, , , . : , . , , . : NSCoding NSData NSKeyedArchiver. NSData . .

. , bplist ( B inary Plist ), . : Xcode , XML , : plutil -convert xml1 MyFile.plist
. , plutil JSON, - , .

NSUserDefaults, . , ~/Library/Preferences/com.yourcompany.yourapp.plist (, , , , bplist), . , ? NSPropertyListSerialization , Cocoa.

, ? , NSDictionary NSArray NSData, plist. , , : NSData NSDictionary NSArray.

: ( ) , .

- (IBAction)savePlist:(id)sender { NSMutableDictionary *root = [NSMutableDictionary dictionary]; [root setObject:@YES forKey:@"autosave"]; [root setObject:@"hello" forKey:@"greet-text"]; [root setObject:@"4F4@@" forKey:@"identifier"]; NSMutableArray *elements = [NSMutableArray array]; [elements addObject:@"one"]; [elements addObject:@"two"]; [elements addObject:@"thee"]; [root setObject:elements forKey:@"elements"]; NSMutableArray *subs = [NSMutableArray array]; for (NSInteger i = 0; i < 10; i++) { NSMutableDictionary *dict = [NSMutableDictionary dictionary]; [dict setObject:[NSString stringWithFormat:@"John %ld", i] forKey:@"name"]; [dict setObject:[NSString stringWithFormat:@"Moscow %ld", i] forKey:@"city"]; [dict setObject:[NSNumber numberWithInteger:i] forKey:@"id"]; [subs addObject:dict]; } [root setObject:subs forKey:@"subs"]; NSLog(@"saving data:\n%@", root); NSError *error = nil; NSData *representation = [NSPropertyListSerialization dataWithPropertyList:root format:NSPropertyListXMLFormat_v1_0 options:0 error:&error]; if (!error) { BOOL ok = [representation writeToFile:self.plistFileName atomically:YES]; if (ok) { NSLog(@"ok!"); } else { NSLog(@"error writing to file: %@", self.plistFileName); } } else { NSLog(@"error: %@", error); } }
, , , :

<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>autosave</key> <true/> <key>elements</key> <array> <string>one</string> <string>two</string> <string>thee</string> </array> <key>greet-text</key> <string>hello</string> <key>identifier</key> <string>4F4@@</string> <key>subs</key> <array> <dict> <key>city</key> <string>Moscow 0</string> <key>id</key> <integer>0</integer> <key>name</key> <string>John 0</string> </dict> <dict> <key>city</key> <string>Moscow 1</string> <key>id</key> <integer>1</integer> <key>name</key> <string>John 1</string> </dict> <!-- --> </array> </dict> </plist>
, ? ! XML . :

{ autosave = 1; elements = ( one, two, thee ); "greet-text" = hello; identifier = "4F4@@"; subs = ( { city = "Moscow 0"; id = 0; name = "John 0"; }, { city = "Moscow 1"; id = 1; name = "John 1"; } ); }
.

:

- (IBAction)loadPlist:(id)sender { NSData *plistData = [NSData dataWithContentsOfFile:self.plistFileName]; if (!plistData) { NSLog(@"error reading from file: %@", self.plistFileName); return; } NSPropertyListFormat format; NSError *error = nil; id plist = [NSPropertyListSerialization propertyListWithData:plistData options:NSPropertyListMutableContainersAndLeaves format:&format error:&error]; if (!error) { NSMutableDictionary *root = plist; NSLog(@"loaded data:\n%@", root); } else { NSLog(@"error: %@", error); } }
? ! JSON-, ! , , : NSDictionary . .

, "mutable" , NSPropertyListMutableContainersAndLeaves . NSPropertyListImmutable , NSMutableDictionary, NSDictionary, .

, PLIST Cocoa. , , .

!

UPD: mejedi , plain-XML .

XML ┬л ┬╗, ( , ┬лhello world┬╗ , ).

, тАФ 10.6 , , 10.8 , - ( __CFBinaryPlistWrite).


Source: https://habr.com/ru/post/In158727/


All Articles