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 6812017
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T20:23:55+00:00 2026-05-26T20:23:55+00:00

So I have an extensive hierarchy of UITableViewControllers that I need to navigate through.

  • 0

So I have an extensive hierarchy of UITableViewControllers that I need to navigate through. Each one is going to need it’s own Custom View Controller. My data-source for any particular tableview is currently an array of strings, like “A,B,C,D,E,F”. My didSelectRowAtIndexPath method is a long list of if statements, like this (pseudocode):

if cell.text = "A"
    alloc init AViewController
    navigationController push aViewController
if cell.text = "B"
    alloc init BViewController
    navigationController push bViewController

I think this is messy. There has got to be a cleaner way to do this. Any “best practices” for this? My best idea is to make a custom class that contains a cellTitle and a viewController Class. Then I can use an array of those as my datasource, and do this kind of thing:

UITableViewController *newView = [custom.viewControllerClass alloc] init...

Thoughts?

  • 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-26T20:23:56+00:00Added an answer on May 26, 2026 at 8:23 pm

    Add a property on your top-level table view controller:

    @property (strong) NSDictionary *viewControllerClassForCell;
    

    In viewDidLoad or other initialization method:

    viewControllerClassForCell = [NSDictionary dictionaryWithObjectsAndKeys:
        [AViewController class], @"A",
        [BViewController class], @"B",
        // etc.
        nil];
    

    In didSelectRowAtIndexPath:

    Class vcClass = [self.viewControllerClassForCell objectForKey:cell.text];
    [self.navigationController pushViewController:[[vcClass alloc] initWithNibName:nil bundle:nil] animated:YES];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a page in one of my client's websites that generates an extensive
I have a webforms page that makes quite extensive use of AJAX. There are
I have an old project that is mixed C and C++. It makes extensive
Suppose that you have the following hierarchy of statistics-related classes, structured in a manner
I'm technically savvy but don't have extensive experience with servers/daemons (I'm a Windows guy,
I have an extensive menu in which I would like to search for and
I have a simple unit test case (extensive question here ) on a configuration
After an extensive search I have been unable to find any information on this
First up: we are not doing TPH (table per hierarchy), that would make this
Willing to admit I'm a complete .NET newbie, but I have extensive experience in

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.