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

WPF vs Windows Forms in desktop applications

.net wpf winforms

I've been developing C# Windows Forms applications for a couple of years and while I've heard and read about WPF I've never really come in close contact to it. With some time to spare this spring I

SQL injection on Classic ASP pages with parameterized queries: text fields

sql-server asp-classic sql-injection

I've parameterized my queries in my Classic ASP app, but am unsure whether I need to sanitize or scrub free text fields or if the parameterization is sufficient to prevent injection.

ibtool failed when compiling storyboard

xcode osx storyboard xcode4.5

I just downloaded a project from a git repository on two different Macbooks. On the first, it runs without problem.

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.