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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T19:21:00+00:00 2026-06-15T19:21:00+00:00

I have a UIViewController in my iOS application that displays a table that is

  • 0

I have a UIViewController in my iOS application that displays a table that is derived from an NSMutableArray. The cells in this table each refer to a unique UIViewController that is called when the user makes a selection. What I am trying to do in my “didSelectRowAtIndexPath:” method is to dynamically create the UIViewController via an NSMutableDictionary that contains keys that match the values in the NSMutableArray that the table is built from, as well as values that contain the corresponding Class names for the respective UIViewController that needs to be called. Because the list is rather long, I figure I need to do this using a for loop, but I am a bit confused as to how to do it. My NSMutableDictionary looks like this:

NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];
    [dict setObject:@"aViewController" forKey:@"SelectionA"];
    [dict setObject:@"bViewController" forKey:@"SelectionB"];
    [dict setObject:@"cViewController" forKey:@"SelectionC"];

and my NSMutableArray that is the basis for my TableView looks like this:

NSMutableArray *myArray = [[NSMutableArray alloc] initWithObjects:@"SelectionA", @"SelectionB", @"SelectionC",...,nil];

How would I obtain a reference to the value inside the cell, and then construct a for loop that would dynamically create the correct viewController that corresponds to the selection made by the user from the tableView, and then take the user to that viewController via the navigationController?

Thanks in advance to all who reply.

  • 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-06-15T19:21:02+00:00Added an answer on June 15, 2026 at 7:21 pm

    If you really need a view controller for each cell, there’s no need to use a dictionary to look them up. Since selection will be by index path, an array is a better choice.

    Create a custom object that has two properties: the name you want to display in the cell and a pointer to the view controller you want to push when it’s selected. Load myArray with these objects instead of strings. When you are populating a cell, select the object that matches the row and use its name. When a cell is tapped, select the object that matches the row and push its controller.

    (But, as others have said, if you can use the same controller and only change the data, that’s the way to go!)

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

Sidebar

Related Questions

I'm developing an iOS 4 application. I have this ViewController: @interface BlogViewController : UIViewController
I have found a crash in an iPhone application with target iOS 4 that
I have an iOS application that was developed using Xcode Version 4.5.1. My iOS
I would like to add admob at my ios application. I have follow that
I have an iOS application that uses core data. I've built my NSManagedObjectModel .
I have a problem with data in UITableView. I have UIViewController, that contains UITableView
I have a UIViewController (which sits inside a tabUIController). Within this UIViewController, I want
During application development I have problems to support the right application architecture. This is
I have an application that plays videos via a MPMoviePlayerViewController that's presented after a
I'm trying to do some simple animation. I have a UIViewController that has two

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.