Arrays within arrays in a plist
I am really struggling on this one; I have read many different posts and the apple literature but to no avail. I have the following plist in my app:
<?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>7A</key> <dict> <key>Title</key> <string>Cells</string> <key>Subunits</key> <array> <string>Some</string> <string>Text</string> <string>In</string> <string>Here</string> </array> </dict> <key>7B</key> <dict> <key>Title</key> <string>Reproduction</string> <key>Subunits</key> <array> <string>Different</string> <string>Text</string> <string>In</string> <string>Here</string> </array> </dict>
In the tableview that I have, I can display the 7A and 7B by using an array to hold "allKeys". The problem I am facing now is what to do when clicked. I've used a property to pass to the next viewcontroller the selected cell as a string and the original dictionary. However, I can't seem to "drill down" to the Subunits array. Any help would be much appreciated. Many thanks.
NSDictionary* dict; // as loaded from your plist file NSString* selectedKey = @"7A"; NSDictionary* subDict = [dict objectForKey:selectedKey]; NSArray* subunits = [subDict objectForKey:@"Subunits"];
Then subunits should be an array of NSStrings.