Graphics Programs Reference
In-Depth Information
Like NSString , the classes NSDictionary and NSArray have writeToFile:
and initWithContentsOfFile: methods. To write collection objects to the filesys-
tem with these methods, the collection objects must contain only property list serializable
objects. The only objects that are property list serializable are NSString , NSNumber ,
NSDate , NSData , NSArray , and NSDictionary . When an NSArray or NSDic-
tionary is written to the filesystem with these methods, an XML property list is created.
An XML property list is a collection of tagged values:
<?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">
<array>
<dict>
<key>firstName</key>
<string>Joe</string>
<key>lastName</key>
<string>Conway</string>
</dict>
<dict>
<key>firstName</key>
<string>Aaron</string>
<key>lastName</key>
<string>Hillegass</string>
</dict>
</array>
</plist>
XML property lists are a convenient way to store data because they can be read on nearly
any system. Many web service applications use property lists as input and output. The
code for writing and reading a property list looks like this:
NSMutableDictionary *d = [NSMutableDictionary dictionary];
[d setObject:@"A string" forKey:@"String"];
[d writeToFile:@"/some/pat/file" atomically:YES];
Search WWH ::




Custom Search