Hello, in my app I have a section where I load from a saved plist which has 2 nested dictionaries like this:
<?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>1</key>
<dict>
<key>color</key>
<string>yellow</string>
<key>lang</key>
<string>US</string>
<key>name</key>
<string>Peter</string>
<key>uid</key>
<string>1</string>
</dict>
<key>2</key>
<dict>
<key>color</key>
<string>blue</string>
<key>lang</key>
<string>US</string>
<key>name</key>
<string>Josh</string>
<key>uid</key>
<string>2</string>
</dict>
<key>3</key>
<dict>
<key>color</key>
<string>red</string>
<key>lang</key>
<string>DE</string>
<key>name</key>
<string>Susan</string>
<key>uid</key>
<string>3</string>
</dict>
</dict>
</plist>
Now I want to access string like outer dictionary from key 2, value for inner key color (blue) I tried make 2 loops, and it works for the outer dictionary but I can't access the inner
NSMutableDictionary *savedData = [NSMutableDictionary dictionaryWithContentsOfFile:path]; // This contains all data from plist
for (int x=0; x<[savedData count]; x++) {
NSString *itemNumber = [NSString stringWithFormat:@"%d", x+1];
//This prints out the correct inner dictionary
NSLog(@"item#%@: %@",itemNumber,[savedData objectForKey:itemNumber]);
for (NSDictionary *dict in [savedData objectForKey:itemNumber]) {
//prints out color, lang, uid, but no key-value pairs
NSLog(@"dict: %@",dict);
}
}
I'd like to know how to directly access key value pairs inside the inner dictionary, could anyone give me a kick in the right direction, please?