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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T22:18:13+00:00 2026-06-03T22:18:13+00:00

In another question ( how to instantiate an object of class from string in

  • 0

In another question ( how to instantiate an object of class from string in Objective-C? ), this was suggested:

id myclass = [[NSClassFromString(@"MyClass") alloc] init];
[myclass FunctioninClass];

However, [myClass FunctioninClass] yields an error because the compiler has no idea if FunctioninClass exists.

I do know the classes that can be there are all descendants of one parent. And that parent has the prototype of the method I want to call, except I want to call the overridden descendant method. Does that suggest a solution?

  • 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-03T22:18:14+00:00Added an answer on June 3, 2026 at 10:18 pm

    After @user523234’s comment, I decided to improve my answer and correct it. His answer, however, is in my opinion not good enough and will crash your code in case the selector is not available.

    So here is the solution:

    id myclass = [[NSClassFromString(@"MyClass") alloc] init];
    
    if ([myclass respondsToSelector:@selector(FunctioninClass)])
    {
        [myClass performSelector:@selector(FunctioninClass)];
    }
    

    Using the – respondsToSelector: will make sure you check wether the sector exists in the class. However, you will need to use the preformSelector everytime. I am unsure if you can dynamically type-cast an identifier.

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

Sidebar

Related Questions

Another question related to this one . I have a List<SortableObjects> that is the
Another question of mine about optimizing Objective C programs inspired the following: does anyone
Answering another question about how const string data was stored in an executable a
From another question I recently posted, it seems that Classic ASP might not be
In another question, a user posted the following reflog: 8c48bab HEAD@{16}: checkout: moving from
In another question , the accepted answer suggested replacing a (very cheap) if statement
UPDATE NOTE: After Debugging, I asked another question with the results: Class Constructor fails
Let's say I have a class Base with a single member message (String). Another
This is an offshoot question that's related to another I asked here . I'm
This question is related to another one that I posted recently: Understanding HttpServletRequest and

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.