Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5938511
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T15:41:47+00:00 2026-05-22T15:41:47+00:00

I have a Sectioned Tableview sourced from a pList which I want to drill

  • 0

I have a Sectioned Tableview sourced from a pList which I want to drill down into children sub views. My only problem is I’m stuck on getting it to populate after first drill down (Entree is the only one with content), “Description” and “Title”.

pList

<?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">
<array>
    <dict>
        <key>Rows</key>
        <array>
            <dict>
                <key>Title</key>
                <string>Entree</string>
                <key>Children</key>
                <array>
                    <dict>
                        <key>Title</key>
                        <string>Garlic Bread</string>
                        <key>Description</key>
                        <string>Cottage loaf smeared with garlic butter and herbs</string>
                        <key>Price</key>
                        <string>8.0</string>
                    </dict>
                    <dict>
                        <key>Title</key>
                        <string>Bruschetta</string>
                        <key>Description</key>
                        <string>Veggies n shit on toast</string>
                        <key>Price</key>
                        <string>9.0</string>
                    </dict>
                </array>
            </dict>
            <dict>
                <key>Title</key>
                <string>Mains</string>
            </dict>
            <dict>
                <key>Title</key>
                <string>Dessert</string>
            </dict>
            <dict>
                <key>Title</key>
                <string>Sides</string>
            </dict>
        </array>
        <key>Title</key>
        <string>Eat</string>
    </dict>
    <dict>
        <key>Title</key>
        <string>Drink</string>
        <key>Rows</key>
        <array>
            <dict>
                <key>Title</key>
                <string>Red</string>
            </dict>

        </array>
    </dict>
</array>
</plist>

MenuViewController.h

#import <UIKit/UIKit.h>


@interface MenuViewController : UITableViewController {
    NSArray *tableDataSource;   
    NSString *CurrentTitle;
    NSInteger CurrentLevel;

}
@property (nonatomic, retain) NSArray *tableDataSource;
@property (nonatomic, retain) NSString *CurrentTitle;
@property (nonatomic, readwrite) NSInteger CurrentLevel;

@end

MenuViewController.m

    #import "MenuViewController.h"

    @implementation MenuViewController
    @synthesize tableDataSource;
    @synthesize CurrentLevel, CurrentTitle;

    - (void)viewDidLoad
    {
        [super viewDidLoad];


        if(CurrentLevel == 0) {

            self.tableDataSource = [NSArray arrayWithContentsOfFile: [[NSBundle mainBundle] pathForResource: @"MenuData" ofType: @"plist"]];

            self.navigationItem.title = @"Menu";
        }
        else 
            self.navigationItem.title = CurrentTitle;
    }



    - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
    {
    #warning Potentially incomplete method implementation.

        return [tableDataSource count];
    }

    - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
    {
    #warning Incomplete method implementation.

        return [[[tableDataSource objectAtIndex: section] 
                 objectForKey: @"Rows"] count];
    }

    - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {

        return [[tableDataSource objectAtIndex: section] 
                objectForKey: @"Title"];

    }

    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
    {
        static NSString *CellIdentifier = @"Cell";

        UITableViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:CellIdentifier];

        NSDictionary *dictionary = [[[self.tableDataSource objectAtIndex: indexPath.section] objectForKey: @"Rows"] objectAtIndex: indexPath.row];

        if (cell == nil) {
            cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];

            cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
        }

        *//The problem is right here, im just stuck on how to access this property correctly
        **cell.textLabel.text = [dictionary objectForKey:@"Title"];***
        // Configure the cell...

        return cell;
    }

    /*
    // Override to support conditional editing of the table view.
    - (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
    {
        // Return NO if you do not want the specified item to be editable.
        return YES;
    }
    */





    /*
    // Override to support conditional rearranging of the table view.
    - (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath
    {
        // Return NO if you do not want the item to be re-orderable.
        return YES;
    }
    */

    #pragma mark - Table view delegate

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    // Navigation logic may go here. Create and push another view controller.
    /*
     <#DetailViewController#> *detailViewController = [[<#DetailViewController#> alloc] initWithNibName:@"<#Nib name#>" bundle:nil];
     // ...
     // Pass the selected object to the new view controller.
     [self.navigationController pushViewController:detailViewController animated:YES];
     [detailViewController release];
     */

    NSDictionary *dictionary = [[[self.tableDataSource objectAtIndex: indexPath.section] objectForKey: @"Rows"] objectAtIndex: indexPath.row];

    //Get the children of the present item.
    NSArray *Children = [dictionary objectForKey:@"Children"];

    if([Children count] == 0) {
        MenuDetailViewController *mdvController = [[MenuDetailViewController alloc] initWithNibName:@"MenuDetailView" bundle:[NSBundle mainBundle]];
        [self.navigationController pushViewController:mdvController animated:YES];
        [mdvController release];
    }
    else {

        //Prepare to tableview.
        MenuViewController *mvController = [[MenuViewController alloc] initWithNibName:@"MenuViewController" bundle:[NSBundle mainBundle]];

        //Increment the Current View
        mvController.CurrentLevel += 1;

        //Set the title;
        mvController.CurrentTitle = [dictionary objectForKey:@"Title"];

        //Push the new table view on the stack
        [self.navigationController pushViewController:mvController animated:YES];

        mvController.tableDataSource = Children;

        [mvController release];
    }
}

    @end
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T15:41:48+00:00Added an answer on May 22, 2026 at 3:41 pm

    You can drill data in recursive manner.
    For root view controller cell selection method
    you have to modify your code as

    - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
        if(self.currentLevel=0)
            return [tableDataSource count];
        else
            return 1;//You require only one section in later levels
    }
    
    - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
        if(self.currentLevel=0)
            return [[[tableDataSource objectAtIndex: section] objectForKey: @"Rows"] count];
        else
            return [tableDataSource count];// Number of children
    }
    
    - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
    
        if(self.currentLevel=0)
            return [[tableDataSource objectAtIndex: section] objectForKey: @"Title"];
        else
            return self.title;//Or your custom title
    
    }
    
    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
        static NSString *CellIdentifier = @"Cell";
    
        UITableViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:CellIdentifier];
        NSDictionary *dictionary = nil;
        if(self.currentLevel=0)
            dictionary= [[[self.tableDataSource objectAtIndex: indexPath.section] objectForKey: @"Rows"] objectAtIndex: indexPath.row];
        else 
           dictionary = [self.tableDataSource objectAtIndex: indexPath.row];
        if (cell == nil) {
            cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
    
            cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
        }
    
        cell.textLabel.text = [dictionary objectForKey:@"Title"];
        // Configure the cell...
    
        return cell;
    }
    
    - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { 
    
        if(self.currentLevel=0)
            dictionary= [[[self.tableDataSource objectAtIndex: indexPath.section] objectForKey: @"Rows"] objectAtIndex: indexPath.row];
        else 
           dictionary = [self.tableDataSource objectAtIndex: indexPath.row];
    
        if([dictionary objectForKey:@"Children"]!=nil){
    
            //Drill down only if you have child
            //Now drilling down logic
            id Object = [dictionary objectForKey:@"Children"];
            NSString * title = [dictionary objectForKey:@"Title"];
    
            if([object isKindOfClass:[NSArray class]) {
                NSArray * dataSource = (NSArray *)object;
                MenuViewController * viewController = [[MenuViewController alloc] initWithNibName:@"YourNibName" bundleNameOrNil:nil];
                viewController.title = title;
                viewController.tableDataSource = dataSource;
                viewController.currentLevel = self.currentLevel+1;
                [self.navigationController pushViewController:viewController animated:YES];
                [viewController release];
            } else if([object isKindOfClass:[NSDictionary class]) {
                //Only one child in the form of dictionary
                //Initialize your detail view controller and push to nav stack
                YourDetailViewController * viewController = [[YourDetailViewController alloc] initWithNibName:@"YourNibName" bundleNameOrNil:nil];
                viewController.data = (NSDictionary*)object;//Pass the view data(price etc)
                viewController.currentLevel = self.currentLevel+1;
                [self.navigationController pushViewController:viewController animated:YES];
                [viewController release];
            } else {
                //Error drilling down is not possible
            }
        }
    }
    

    Hope this will sort out your drilling problem.. 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want a viewController's view have a tableView as its subview. Since I need
I have a table into wich I'd like to mix some custom cells and
My application have UI similar to Phone.app->Recents: sectioned UITableView and a UISegmentedControl in the
I have spent hours reading a couple dozen different blogs and others q's here
I have an NSArray of objects: MyObject consists of the following string properties: Title
I have created an editable UITableView that supports several custom UITableViewCells of my own
I am using custom cells for different sections within my tableview. I know that
I have four sections in my UITableView, how do I add a header for
I've created a custom UIView, and inside that UIView, I add a UITableView like
I'm currently having the following issue in my project: I'm using Core Data to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.