0

I am developing a document-based app. I am using a dedicated window controller for the document window, and calling the -[NSDocument makeWindowControllers] method.

My window controller is initialized like this:

- (instancetype) init
{
    if (self = [super initWithWindowNibName:@"Document" owner:self]) {

    }

    return self;
}

Here, @"Document" is the .xib file containing the main document window that was created with the project.

The rationale here is that, this window controller is always initialized with this type of window, so the parameter is both hard-coded and hidden away inside the implementation of -init (while also conveniently setting the window owner to self).

So, the side that instantiates the window controller (in my case, the document class) doesn't need to worry about which nib to use and can just call -init.

The problem is, I am breaking the designated initializer chain and Xcode complains with these warnings:

Semantic Issue Method override for the designated initializer of the superclass '-initWithCoder:' not found.

Semantic Issue Designated initializer missing a 'super' call to a designated initializer of the super class.

Semantic Issue Method override for the designated initializer of the superclass '-initWithWindow:' not found.

Semantic Issue Designated initializer invoked a non-designated initializer.

I would switch the call to -initWithWindowNibName:owner: with one to -initWithWindow: (and after that, set the owner manually, I guess?); but I don't know how to create an NSWindow directly from a nib (or if this is the right thing to do).

EDIT: I just discovered that the warnings are being triggered only because I labeled -init as NS_DESIGNATED_INITIALIZER in my interface. I can remove that label and the warnings go away, but -init is my de-facto designated initializer so I would rather keep it.

Nicolas Miari
  • 16,006
  • 8
  • 81
  • 189

0 Answers0