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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T04:01:31+00:00 2026-05-29T04:01:31+00:00

so I have subclassed a UIViewController that I create. The question is, is there

  • 0

so I have subclassed a UIViewController that I create. The question is, is there a way so that I can force to call a method using the subclassed one if the one I am creating is the super class. I know this is stupid, as it’s the same as forcing a mammal to call a dog’s behavior. But before doing this, I am actually making sure first that that mammal is a dog, otherwise I won’t call it. Is this a bad thing to do? If not then how can I do such thing? I tried casting the superclass into it’s subclass and then do a method call, but it doesn’t work. Any thoughts?

So what I am trying to do. I have a UIViewController A and a subclass of that B. If I have A and I want to call B’s method that overrides A, how do I do that? I hope this is clear

  • 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-29T04:01:32+00:00Added an answer on May 29, 2026 at 4:01 am

    There is a difference between how you declare your object and what it actually is.
    Consider this example:

    Mammal *mammal = [[Dog alloc] init]; //Dog is a subclass of Mammal
    

    Here, you have a pointer to a Mammal object which actually points to an instance of the specialized Dog class. This is valid because a mammal has all the methods that a dog has.

    You can check if some Mammal instance is actually a Dog by using isKindOfClass:, like this:

    if ([mammal isKindOfClass:[Dog class]]) {
        [(Dog *)mammal bark];
    }
    

    This is perfectly valid. If however you would have created your mammal with [[Mammal alloc] init], the check for the Dog class would fail and you would not be able to call any methods that only Dog has. If you wouldn’t do the check, this would actually crash, because the casting does not change the object in any way, it just tells the compiler “I know what I’m doing, don’t warn me”.

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

Sidebar

Related Questions

I have a parent class (A) that is UIViewController. Than i create class B
I subclassed UIViewController as STViewController and noticed that classes inheriting from STViewController have their
I have a UIViewController subclass that I am trying to have handle the shake
I have subclassed UIViewController into a new class, PageViewController (I'm writing a simple book
I have subclassed java.awt.Frame and have overridden the paint() method as I wish to
In a UIViewController subclass I create a bar button item that fires an event
I have a UIViewController subclass called TripViewController. This class has the following method: -
I have a UITabBarController, and each tab handles a different UIViewController that pushes on
I have subclassed UIView and created a NIB that controls the main logic for
I have subclassed MPMoviePlayerController... @interface CustomMoviePlayerController : UIViewController { NSURL *movieUrlPath; MPMoviePlayerController *mp; ...

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.