views:

49

answers:

1

I'm stuck in a rut over implementing a sectioned plist into a UITableView.

My plist setup is as followed. I have a root array with dictionaries representing sections. These dictionaries have a single string 'sectionname' that dictates the section header as well as an array of dictionaries inside to represent the cells (the reason for this was to allow the cells to be counted and still have a section header).

Root - Array
   Item 0 - Dictionary  
       sectionname - string - A
       RowsInSection - Array
          Item 0  - Dictionary
             name - string - Adam
          Item 1 - Dictionary
             name - string - Andrew
   Item 1 - Dictionary
       sectionname - string - B
       RowsInSection - Array
          Item 0 - Dictionary
             name - string - Belle
          Item 1 - Dictionary
             name - string - Bob
   Item 3 - Dictionary

[And so forth].

Now, everything appears to be working, the correctly named headers are there and the correct number of rows are under their sections. However, the rows do not have labels and for the life of me I can't figure out why.

I have a NSMutableArray of the plist

    libraryContent = [[NSMutableArray alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:libraryPlist ofType:@"plist"]];

The number of rows in section is thusly.

NSInteger count = [[[[doa libraryContent] objectAtIndex:section] valueForKeyPath:@"RowsInSection.@count"]intValue];
return count;

And the titles for headers.

return [[[doa libraryContent] objectAtIndex:section] objectForKey:@"sectionname"];

I tried with the following to no avail.

cell.textLabel.text = [[[doa libraryContent] objectAtIndex:indexPath.row] valueForKey:@"name"];

I'm still learning and this was kind of botched together from different places. The 'doa' method links to another file where the 'libraryContent' is declared.

Do you guys have any idea how to get the names out of the plist? Or any other methods of doing what I'm trying to?

A: 
Michael Kessler
Thanks for that, it worked perfectly. I had tried a million different variations and I was -this- close to solving it. Again, thanks for the help.
Ryan
Happy that I could help you. I will appreciate if you will accept the answer.
Michael Kessler