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.

Answers


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.


Need Your Help

sphinx: formatting multiline docstrings

python documentation python-sphinx

Using sphinx autodoc, is there a way to format a first line of a multiline docstring in a special way?

Angular Form not submitting on first click

angularjs forms

I have built a small angular App into my website whereby a user enters a searchterm into an input field and then values are returned via an Angular service. When I attempt to submit a value however...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.