NSDictionary
<?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>arrayKey</key>
<array>
<string>string1</string>
<string>string2</string>
<string>string3</string>
<string>string4</string>
</array>
<key>dicKey</key>
<dict>
<key>key1</key>
<string>object1</string>
<key>key2</key>
<string>object2</string>
<key>key3</key>
<string>object3</string>
</dict>
<key>key2</key>
<string>object2</string>
<key>key3</key>
<string>object3</string>
</dict>
</plist>
NSArray
<?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>
<string>string1</string>
<string>string2</string>
<string>string3</string>
<dict>
<key>key1</key>
<string>object1</string>
<key>key2</key>
<string>object2</string>
<key>key3</key>
<string>object3</string>
</dict>
<string>string5</string>
</array>
</plist>
At the end, after </plist>, there’s another CR.
example NSArray NSDIctionary plist xml
490‘Initial interface orientation’ setting in Info.plisy
246writeToFile – quick file writing
243Stepping over an Array (or Dictionary)
220Linking libxml2 in Xcode
214NSMutableArray: setObject vs. setValue
NSArray *paths = [[NSFileManager defaultManager]
directoryContentsAtPath: NSHomeDirectory()];
<del datetime="2010-04-01T02:49:15+00:00">
// either like that...
NSEnumerator *e = [paths objectEnumerator];
for (NSString *p in e) {
NSLog(@"path: %@", p);
}
// or like that.
for (NSString *p in [paths objectEnumerator]) {
NSLog(@"path: %@", p);
}
NSDictionary has both [myDict objectEnumerator] and [myDict keyEnumerator].
Fast Enumberation is a feature in Objective-C 2.0, it allows you to step over arrays and dictionaries in a fast, consice, and secure (guarded against mutations) manner.
for (NSString *p in paths) {
NSLog(@"path: %@", p);
}
// or
NSString *p;
for (p in paths) {
NSLog(@"path: %@", p);
}
Sometimes things are really as simple as they should be.
2.0 Enumberation Fast NSArray NSDIctionary NSEnumerator Objective-C
576NSDictionary and NSArray plist examples
569Layering one UIImage onto of another UIImage
560#import vs #include in Objective C – A quick reminder
457Singleton Classes and Shared Resources in Objective-C
420Getting current Time with Microseconds