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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T04:28:02+00:00 2026-06-16T04:28:02+00:00

I have several viewControllers in my application that I want to inherit from a

  • 0

I have several viewControllers in my application that I want to inherit from a single parent viewController which of course, extends UIViewController (thus making all of the viewController classes with the exception of the parent, sibling classes). What I would like to know (and I am new to inheritance in Objective-C), is that in my parent viewController class, I am declaring a parameter in the .h file called, NSString *name, which I will be marking as a @property (nonatomic, retain), and then synthesizing in my .m file.

After doing this in the parent class, do I have access to the NSString *name parameter in the child viewControllers, or do I have to declare a separate parameter in each respective viewController class that inherits from the parent class? Each viewController will have a unique value for the NSString *name parameter, and if this is the case, do I need to create a separate parameter for each viewController class, or would it be sufficient for me to simply create it once inside the parent class?

I also want to confirm that if I declare any methods in the parent class, that I would be able to access them using a reference from the sub-classes (so long as that method is not overridden in the child class), as I am able to in Java? My guess is yes, since this is one of the essential principles of 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-06-16T04:28:03+00:00Added an answer on June 16, 2026 at 4:28 am

    If each view controller has a unique value, and that value is immutable, then you can simply override the getter for your name property and return a value unique to that view controller:

    - (NSString *)name {
        return @"The name of this view controller";
    }
    

    If you would like to be able to mutate the result, you can declare either an iVar, or a property with a different name, then return that in a getter for the class:

    - (NSString *)name {
        return _myNameiVar;
    }
    

    Also, to answer your second question, Variables, Methods, and even Properties declared inside the method file of a class are invisible to subclasses, where methods and properties declared in the header are visible to all that import the header. iVars can always be accessed through the struct access operator (->), but unless they are marked @public, the compiler will discourage you from going this route.

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

Sidebar

Related Questions

In my app I have a xib that has several viewcontrollers and xibs (with
I have an application with several view controllers controlled from a tab bar controller.
I have several ViewControllers which subclass UITableViewController and have a Xib file where I
In my mainWindow.xib, I have this setup. 1) UINavigationController containing several viewControllers. 2) UIViewController
I need to create an application that should have several themes. It means that
Let's imagine you have a fullscreen C++ desktop application that consists of several screens
I have a viewController that has a button which, when clicked, dynamically creates a
I have several viewControllers controlled by a navigation controller. For example, viewController A and
I have several xml files with different node structure. I want to extract xml
I have several HTML elements (buttons) that fire the same JQuery AJAX request. When

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.