PDA

View Full Version : Navigate plists?




Danneman101
Jul 23, 2010, 08:34 PM
Im having a little trouble navigating a plist in a tableview.

MENU.plist

Root (Array)

-> Item 0 (String) (LEVEL 1)

--> Item 0 (String) (LEVEL 1.1)
--> Item 0 (String) (LEVEL 1.2)
--> Item 0 (String) (LEVEL 1.3)

-> Item 0 (String) (LEVEL 2)

--> Item 0 (String) (LEVEL 2.1)
--> Item 0 (String) (LEVEL 2.2)
--> Item 0 (String) (LEVEL 2.3)

-> Item 0 (String) (LEVEL 3)

--> Item 0 (String) (LEVEL 3.1)
--> Item 0 (String) (LEVEL 3.2)
--> Item 0 (String) (LEVEL 3.3)


I know how to populate the tableview with the values: [LEVEL 1, LEVEL 2, LEVEL 3] using the following code:


myViewController.m

- (void)viewDidLoad {
NSBundel *bundle = [NSBundle mainBundle];
NSString *path = [bundle pathForResource:@"MENU" ofType:@"plist"];
var_CurrentPlist = [[NSArray alloc] initWithContentsOfFile:path];
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
NSArray *temp = [var_CurrentPlist objectAtIndex:indexPath.row];
cell.textLabel.text = [temp objectAtIndex:0];
}


But how do I dig a little deeper into the xml of the plist and populate the same tableview with, for instance, the values [LEVEL 2.1, LEVEL 2.2, LEVEL 2.3]?