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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T09:07:34+00:00 2026-06-09T09:07:34+00:00

In objective-c, how could it be determined in a super class if a specific

  • 0

In objective-c, how could it be determined in a super class if a specific method was overwritten by its (calling) child(ren)?

For example, in the below, child class Z doesn’t override method b, therefor the base class X would do some additional default processing. ZY does however implement b in child-class Y so the default processing would not be required.

// base class X
-(void)a
{
   // do something
}

-(void)b
{
   if("no_child_has_implemented_b") {
      // add some default behavior
   }
}


// child class Y : X
-(void)a 
{
   [super a];
}

-(void)b
{
   [super b];
}


// child class Z : X
-(void)a
{
   [super a];
}

// child class ZY : X
-(void)a
{
   [super a];
}
  • 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-09T09:07:35+00:00Added an answer on June 9, 2026 at 9:07 am

    In a reasonable normal OO design, you shouldn’t have a base class know if a subclass is overriding it. If you find yourself doing that, it’s a code smell, and usually means there is better way of doing things.

    Changing a superclasses’ method behaviour based on whether it is overridden isn’t a good idea in most cases because it means the superclass is second-guessing the behaviour and intent of the subclass. For example, what if one day someone wrote a subclass that wanted to get the default setup afforded by the superclass, for a reason you hadn’t thought of?

    It’s quite regular to have overridden methods in a subclasses call the super version, and the super version does basic setup relevant to its class, and then your subclass’ overridden method gets to do additional things after calling super. If this doesn’t handle your situation, you could just have your subclass’ method not calling the super version of the method — it would just execute its own code.

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

Sidebar

Related Questions

Can a Objective c interface have more than one implementation? Example I could have
Could I parse an NSString to have it call a method that matches its
For instance, I know Objective-C class methods could be overridden and Java's not. What's
How to make a ConstantList class in Objective C of an application which could
Someone on IRC told me I could create objective c objects directly from plist
Note: I'm relatively new to Objective-C and am coming from Java and PHP. Could
Good evening everyone, I was hoping you could help with an Objective-C question I
Objective-C uses a sophisticated message-passing system when one object calls a method on another
Could someone please explain the Objective-C difference between myString and anotherString in the following
Could anyone share the the ways to do the documentation in objective C? Is

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.