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

  • Home
  • SEARCH
  • 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 6528701
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T09:33:32+00:00 2026-05-25T09:33:32+00:00

My NSWindowController has this code: – (id)init { [self initWithWindowNibName:@MyWindow]; [self loadWindow]; return self;

  • 0

My NSWindowController has this code:

- (id)init {
    [self initWithWindowNibName:@"MyWindow"];       
    [self loadWindow];
    return self;
}

- (void)windowDidLoad
{
    [super windowDidLoad];

    NSWindow *window = [self window];
    NSAssert(window != nil, @"Can’t get window!");

    // do some stuff    
}

The NSAssertfails.

Why?

How can I get the window?

  • 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-25T09:33:33+00:00Added an answer on May 25, 2026 at 9:33 am

    There are two issues here. Firstly, your initialiser is missing the assignment to self:

    - (id)init 
    {
        self = [super initWithWindowNibName:@"MyWindow"];
        if(self)
        {
            [self loadWindow];
        }
        return self;
    }
    

    Secondly, and the probable reason that your assertion is failing, is that you have not connected the window outlet of File’s Owner in your nib file to the window object. This means that your window controller doesn’t know what object the window property points to.

    If you don’t understand how to set outlets in Interface Builder then you have a lot of learning to do and you should do a simple tutorial before you do anything else, because understanding how outlets and actions work is fundamental to being able to program with Cocoa.

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

Sidebar

Related Questions

I am trying to open a NSWindow using the following code: NSWindowController *window =
I have saveWindowController (NSWindowController subclass object). I use initWithWindowNibName: method to init the controller.
I have an NSWindowController and I initialize it like this; + (MyWindowController *) sharedController
I have a subclass of NSWindowController that has its own nib and another class
I have the following code: @interface AXWindowController : NSWindowController { IBOutlet NSTextField *text; IBOutlet
Is this ok, to load NSWindowController from NSDocument, and keep reference to NSArrayController? I
In my application, I have a NSWindow that has a NSTableView object and a
My app have Preferences window. I open it using this code - (IBAction)openPreferences:(id)sender {
I have a custom NSWindowController subclass that loads a NIB file during initialization like
I'm seeking further clarification after seeing What is responsible for releasing NSWindowController objects? I'm

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.