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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T11:37:40+00:00 2026-05-21T11:37:40+00:00

Hey developers! I built a Table View, populated it with array objects and I

  • 0

Hey developers!
I built a Table View, populated it with array objects and I implemented a code when a user clicks an object inside my Table View, it loads that object’s own nib file, and I am using an if statement. (just a little note, I populated my Table View with 40 objects because that’s how much things I have and need), so I’ll show only the first two if statements I created at the beginning of my if statement code since I have way too many if statements for all 40 objects in my Table View:

if ([[glossaryArray objectAtIndex:indexPath.row] isEqual:@"Title"]) {
    Title *titleLoad = [[Title alloc] initWithNibName:@"Title" bundle:nil];
    [self.navigationController pushViewController:titleLoad animated:YES];
    [titleLoad release];
    }
    else if ([[glossaryArray objectAtIndex:indexPath.row] isEqual:@"Meta Description Tag"]) {
        MetaDescriptionTag *metaDescriptionTagLoad = [[MetaDescriptionTag alloc] initWithNibName:@"MetaDescriptionTag" bundle:nil];
        [self.navigationController pushViewController:metaDescriptionTagLoad animated:YES];
        [metaDescriptionTagLoad release];
    }
...

So that’s it, I don’t want to be cocky showing all of my if statements, so yep this code works, each array objects loading it’s own separate nib file (40 nib file 1 for each array objects) and each of these nib files are like Web Views, Image Views, Text Fields and other objects. Call me crazy, but this is the only code I can think of right now, so hopefully someone can help me edit this code into a much easier code, thanks

  • 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-21T11:37:41+00:00Added an answer on May 21, 2026 at 11:37 am

    If your values in glossaryArray can be mechanically transformed into the corresponding class/nib name (e.g. by removing all spaces), you could do something like this:

    NSString *className = [self classNameFromString:[glossaryArray objectAtIndex:indexPath.row]];
    UIViewController *viewController = [[NSClassFromString(className) alloc] initWithNibName:nil bundle:nil];
    [self.navigationController pushViewController:viewController animated:YES];
    [viewController release];
    

    If they can’t be mechanically transformed, you could always construct an NSDictionary mapping from one to the other, or special-case the few that are different. Or rename the classes and nibs.

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

Sidebar

Related Questions

Hey, in the Programming Pearls book, there is a source code for setting, clearing
hey all my question about how the developers makes their interface the buttons, slider,
Hey everyone, I'm using Virtual PC and working with a virtual hard disk (*.vhd)
Hey so what I want to do is snag the content for the first
Hey, I'm using Levenshteins algorithm to get distance between source and target string. also
Hey all, my Computational Science course this semester is entirely in Java. I was
Hey, I've been developing an application in the windows console with Java, and want
Hey all. Newbie question time. I'm trying to setup JMXQuery to connect to my
Hey peoples, I've been studying Java for a couple of weeks, and have decided
Hey right now I'm using jQuery and I have some global variables to hold

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.