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

  • Home
  • SEARCH
  • 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 950331
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T23:32:53+00:00 2026-05-15T23:32:53+00:00

In Objective-C, I have a base class A, with instance method -(void) doSomething. Class

  • 0

In Objective-C, I have a base class A, with instance method -(void) doSomething. Class B is derived from A and overwrites doSomething. Class C is derived from B. In the implementation of C’s doSomething, I want to invoke A’s doSomething (instead of B’s). How do I achieve this? I know I can use [super doSomething] to invoke the immediate super-class implementation, but what if I need a more basic implementation higher above in the inheritance tree, like in the case mentioned above. In C++ you would simply do the following:

void C::doSomething()  
{  
    A::doSomething();  
}

How do I achieve the same thing in Objective-C?

  • 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-15T23:32:54+00:00Added an answer on May 15, 2026 at 11:32 pm

    You can extract the code into a static method which takes an instance as an argument. Example:

    @interface A : NSObject
    {
    }
    
    +(void)joe_impl:(A*)inst;
    
    -(void)joe;
    
    @end
    
    @implementation A
    +(void)joe_impl:(A*)inst{
        NSLog(@"joe: A");
    }
    
    -(void)joe{
        [A joe_impl:self];
    }
    @end
    @interface B : A
    {
    }
    
    -(void)joe;
    
    @end
    
    @implementation B
    
    -(void)joe{
        [super joe];
        NSLog(@"joe:B");
    }
    @end
    @interface C : B
    {
    }
    
    -(void)joe;
    
    @end
    
    @implementation C
    
    -(void)joe{
        [A joe_impl:self];
        NSLog(@"joe:C");
    }
    @end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a base class called ModelBase and I have a derived class called
I have two Objective-C classes and one is derived from the other as @interface
I have a C++ class that I'm using from my Objective-C++ controller in my
I have some objective-c code I'm converting from iPhone to iPad. CFGregorianDate is used
Can a Objective c interface have more than one implementation? Example I could have
I have the following class hierachy: @interface Message : NSObject {} @end @implementation Message
I have subclassed NSMutableArray as follows: Base Class: @interface MyBaseMutableArray : NSMutableArray { //
In Objective-C, I have a category for a class: @interface UILabel(CustomInit) - (id)initWithCoder:(NSCoder *)coder;
I have a base object abstract class and a base object collection class for
Ok... in Objective C you can new up a subclass from a static method

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.