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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T00:19:56+00:00 2026-05-25T00:19:56+00:00

I am wanting to use NSClassFromString() to pass a string to so that will

  • 0

I am wanting to use NSClassFromString() to pass a string to so that will be determining what class is pushed onto the nav controller. Problem is, I am wanting to pass a value to this class, which causes an error, as well as trying to push the view controller causes an error since NSObject is not a UIViewController type class.

Class screenClass = NSClassFromString(screen.name);
NSObject* newClass = [[screenClass alloc] init];
newClass.asset = asset; // Causes errors because asset not in NSObject
[self.navigationController pushViewController:newClass animated:YES];// newClass is an NSObject
[newClass release];

Is there a better way to do what I am trying here?

  • 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-25T00:19:56+00:00Added an answer on May 25, 2026 at 12:19 am

    You can’t use dot notation if you can’t statically type the variable. If all all of the possible classes descend from one common class that declares the method, you can statically type it as that class. Otherwise, you’ll need to use the accessor method for the asset property:

    Class screenClass = NSClassFromString(screen.name);
    id newClass = [[screenClass alloc] init]; // note that it's an id to indicate that we don't know what it'll be more specifically than an object
    [newClass setAsset:asset];
    [self.navigationController pushViewController:newClass animated:YES];
    [newClass release];
    

    This assumes that the setter for the asset property is setAsset: (which it normally will be).

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

Sidebar

Related Questions

What are the big limitations with VB.Net that prevent people from wanting to use
I'm wanting to use http_build_query to change an array to html tag properties. Problem
I am wanting to use the g:timeZoneSelect tag within my application, problem is im
I'm wanting to use some newer software that requires Python 2.6 , and we
I'm wanting to use an extension for Python that I found here , but
I have been wanting to use a git command that saves a stash without
I'm wanting to use android:configChanges=orientation|keyboardHidden for a few of my activities so that my
I am wanting to use keywords within a large string. These keywords start and
I am wanting to use the get_class($var) to show the class of an object.
Hi guys im wanting to use direct input in my c# program so that

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.