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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T14:18:51+00:00 2026-06-08T14:18:51+00:00

My app has a large number of view controllers declared in the interface for

  • 0

My app has a large number of view controllers declared in the interface for example:

ViewController_1_0 *viewController_1_0
ViewController_1_1 *viewController_1_1
ViewController_1_2 *viewController_1_2
etc ...

(I realize the underscores are not a good Cocoa coding convention for class names and will change that.)

My intent is to present appropriate controller views based on the current UIStepper value.

Rather than do conditional tests for each of the stepper values and then perform a separate lazy instantiation of the controller object using the “hard coded” view controllers I am trying to have code appearing once using strings constructed based upon the current stepper value.

I’ve figured out (with help from Use a Class name stored in a variable to call a Class method?) how to set up the Class name: I’ve declared a property:

@property(strong, nonatomic) Class classStringClass;

And then after constructing the variable string for the class, I do:

classStringClass = NSClassFromString(classString);

Where classString is the constructed string using the stepper value, equivalent to ViewController_1_0, for example.

I’ve also declared a property for the ivar as:

@property (strong, nonatomic) NSString *classInstanceString;

Therefore I do:

if(!classInstanceString) {
   classInstanceString = [[classStringClass alloc] initWithNibName:classString bundle:nil];
}

Where I am stuck is how to code for the ivar for the controllers, i.e., classInstanceString constructed to be the equivalent of the ivar viewController_1_0 (or whatever based on the stepper value) declared in the interface. Once I get out of the lazy instantiation if statement and then code to access properties of classInstanceString, for example:

classInstanceString.view.hidden = NO;

classInstanceString understandably gets an error “Property ‘view’ not found on object of type ‘NSString'”.

How do I declare ‘classInstanceString’ (or another variable, say ‘classInstanceVariable’ containing the classInstanceString value) so when instantiating it, it is the ivar of classStringClass and has access to the class properties, to use subsequent to the instantiation of the class ? I surmise that it should be a different type than an NSString, but what type would that be, or is there another way to do this ?

  • 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-08T14:18:53+00:00Added an answer on June 8, 2026 at 2:18 pm

    If you just need basic UIViewController ivars you could always cast it to a UIViewController.

    UIViewController *vc = (UIViewController *)[[classStringClass alloc] initWithNibName:classString bundle:nil];
    
    [vc view];// works!
    

    Or if you need custom ivars it would be a good idea if they all extended a base class (or protocol) like so:

    MyBaseViewController *vc = (MyBaseViewController *)[[classStringClass alloc] initWithNibName:classString bundle:nil];
    
    [vc customVar]; //works
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am developing an iPad app that has a large number of UIViewControllers ,
I have a .NET2.0 C# web-app. It has a variable number of large, init-expensive
I'm developing an app which has a large amount of related form data to
I am developing a WP7 app. The app has a pretty large XML Parsing
My WPF application has a feature whereby it renders a large number of images
I'm working on a iPhone app which has a pretty large UITableView with data
I'm in a situation where I've got a project that has a large number
I'm working on a web app where a large number of thumbnails will be
We are getting a large number of SQLiteDiskIOException errors in our Android app, with
We have a large legacy VB app made up of a number of DLLs

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.