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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T23:51:07+00:00 2026-06-04T23:51:07+00:00

I wish to subclass NSWindowController and supply several of the standard init methods (e.g.,

  • 0

I wish to subclass NSWindowController and supply several of the standard init methods (e.g., init, initWithWindow, initWithWindowNibName). At the moment, I have each of the overriden methods call its equivalent super i.e., init calls [super init], initWithWindow calls [super initWithWindow] and so on and so forth.

Is this the proper way of doing things? Or am I setting this up way too generically and should I just provide a single init method that calls whatever super method necessary?

How does NSWindowController actually implement its init methods? According to the documentation, initWithWindow is the ‘default’ initializer – supposedly ‘default’ meaning that the other initialization methods call initWithWindow. Does that mean that when I subclass, I should only have a single initialization method that calls the class’ super?

I am getting confused to the point where I start to laugh hysterically and my dog looks funny at me 😉

  • 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-04T23:51:09+00:00Added an answer on June 4, 2026 at 11:51 pm

    Each class should have one designated initializer. When subclassing, you will typically elect the initializer that contains the most custom parameters, and term it your ‘designated’. The important part is that all other initializers (to include, in particular, the default initializer described for the parent classr), call up to this initializer. Only the ‘designated’ initializer calls super, all others call self.

    For example:

    //The default initializer documented by Apple for a given class:
    - (id)init
    {
        self = [super init];
        return self;
    }
    

    So, let’s say you have several initializers with various options:

    This custom init has the most parameters, and is your new ‘designated’. You’ll notice that it calls [super init]:

    - (id)initWithParamters:(NSObject *)paramterOne andParameter:(NSObject *)paramterTwo
    {
        self = [super init];
        if (self)
        {
            __ivarOne = paramterOne;
            __ivarTwo = parameterTwo;
        }
    
        return self;
    }
    

    You have an additional custom init, but only takes one parameter. Notice that it calls self (NOT super):

    - (id)initWithParamter:(NSObject *)parameterOne
    {
    return [self initWithParamter:parameterOne andParameter:nil];
    }
    

    Finally, override the classes default initializer (as specified in documentation):

    - (id)init
    {
        return [self initWithParamter:nil];
    }
    

    To summarize: You may implement as many custom initializers as you’d like in your subclass. One initializer should be deemed your “designated” initializer, and only this method should implement [super init] (where init is the designated initializer of the super class, which may not be ‘init’). All the other initializers should call [self init] (where init is the designated initializer for your subclass).

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

Sidebar

Related Questions

I have a genericised class that I wish to subclass as follows: public class
For example suppose I have a class Vehicle and I wish for a subclass
I wish to automatically enter a password while running an install script. I have
Wish to know more about the practical differences between init and initWithNibName . SO
I have some StackPanels I wish to have the same Width. However this should
I have a custom QWidget subclass that lays out a number of children. In
I want to create a subclass of UITableView or UIScrollView that will have some
i wish to display 2 different datatables in each tab of the tabview of
Per my previous question , I wish that a boost::shared_ptr<A> was actually a subclass
MyNSImageView is a subclass of NSImageView, here I have: @interface MyNSImageView : NSImageView {

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.