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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T21:26:55+00:00 2026-06-05T21:26:55+00:00

I have an NSWindow set up in Interface Builder. I have set the class

  • 0

I have an NSWindow set up in Interface Builder. I have set the class of File's Owner to my NSWindowController and linked the window property of the controller to my NSWindow.
My controller implements NSWindowDelegate.

Now, in my controller, I have added the following:

- (void)windowDidLoad
{
    [super windowDidLoad];

    [self.window setDelegate:self];
}

- (void)windowDidBecomeMain:(NSNotification *)notification
{
    NSLog(@"Did become main.");
}

Still, -windowDidBecomeMain: isn’t called. Does anyone know why this is?

EDIT:

Trying to show a window from AppDelegate on launch. The main nib (declared in Info.plist) contains a menu item only which is linked to the AppDelegate. In the application delegate, I show an icon on the status bar and when this icon is clicked, I display the menu from the main nib.
In the application delegate, I also want to display a window which should have a window controller assigned to take care of the logic.
I believe that when this works, I will receive my window notifications.

Now, the following code doesn’t show the window and I can’t figure out why.

DemoWindowController *dwc = [[DemoWindowController alloc] initWithWindowNibName:@"DemoWindowController"];
[dwc showWindow:self];

Note that self is the application delegate.

  • 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-05T21:26:57+00:00Added an answer on June 5, 2026 at 9:26 pm

    I suspect your problem is due to the fact that your window controller is not actually the object that is the nibs file owner.

    When you change the class in interface builder you are telling it what outlets and actions are available (which is why you are able to drag to the window outlet) but you are still responsible for passing in this object yourself.

    In the case of a non-document based application, you will have a main method which calls NSApplicationMain. What this does is basically look up and load the window nib that is specified in your info.plist file and pass the current NSApplication instance to this nib as the files owner (so even though you changed the class type to NSWindowController, the object being passed in is actually of type NSApplication).

    The easiest way to fix your problem is to get rid of your window controller for now (as it isn’t actually doing anything yet).

    You should implement the -windowDidBecomeMain: method in your app delegate. Then Ctrl+drag from your window to your appDelegate to set it as the delegate of the window to get your notifications.

    Update

    To answer your question regarding the WindowController beware of the following two issues:

    1. You are creating your window controller variable (dwc) in your applicationDidFinishLaunching: method. This is released the moment you leave the method taking your window with it. Create an instance variable to hold onto the window controller instead.
    2. Ensure that your second window nib has its file owner set to NSWindowController (or your window controller type) and that its window outlet is connected to the window in the nib file.

    Your window should now display.

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

Sidebar

Related Questions

I have a NIB with two NSWindow objects. The controller class has two IBOutlets,
I have an NSWindow that I defined in interface builder. I want to make
How do you change the title of an NSWindow instance? I have one window
lets say I have an NSWindow Class, that has several events for mouse and
I have overloaded NSWindow and have created a custom window of my own (Borderless
I have an NSWindow which contains an NSImageView. This window gets activated everytime I
I have created a simple NSWindow with an NSTextField and an NSButton in Interface
I have a NIB file that I load using NSWindowController initWindowNibName. The NIB file
I have saveWindowController (NSWindowController subclass object). I use initWithWindowNibName: method to init the controller.
I have a WebView in a NSWindow and when I close the window and

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.