Plist loaded in AppDelegate with following structure:
Root ----> Dictionary
Test Item ----> Array
Item 1 ----> Dictionary
HeaderTitle ----> String ----> Section 1
Items ----> Array
Item 1 ----> Dictionary
FirstName ----> String ----> Any Name
SecondName ----> String ----> Another Name
CellIcon ----> String ----> Icon.gif
View ----> Number----> 2
Item 2 ----> Dictionary
FirstName ----> String ----> Any Name 2
SecondName ----> String ----> Another Name 2
CellIcon ----> String ----> Icon2.gif
View ----> Number----> 2
I have a TableViewController.m that requires me to put the above plist structure in a table view that has 5 sections. The problem is I can't get that data to show in the described sections of my table view. I am getting confused in writing a mutable array to accomplish this task. I am already using an array to control the different levels (views) in my table but I am having trouble adding the mutable array to control the sections of the table. The code I have is as follows:
- (void)viewDidLoad {
[super viewDidLoad];
if (CurrentLevel == 0) {
NSArray *tempArray = [[NSArray alloc] init];
self.tableDataSource = tempArray;
[tempArray release];
TheAppDelegate *AppDelegate = (TheAppDelegate *)[[UIApplication sharedApplication] delegate];
self.tableDataSource = [AppDelegate.data objectForKey:@"SampleArray"];
self.navigationItem.title = @"Main";
}
else
self.navigationItem.title = CurrentTitle;
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return [menuSections count];
}
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
NSDictionary *menuSection = [menuSections objectAtIndex:section];
return [menuSection objectForKey:@"HeaderTitle"];
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
NSArray *menuItems = [[menuSections objectAtIndex:section] objectForKey:@"Items"];
return [menuItems count];
}