• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Main Window Disappears when Loaded from Separate NIB File
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Main Window Disappears when Loaded from Separate NIB File


  • Subject: Re: Main Window Disappears when Loaded from Separate NIB File
  • From: Steven Degutis <email@hidden>
  • Date: Tue, 07 May 2013 16:57:13 -0500

ARC is on. Retain the window controller.

On Tue, May 7, 2013 at 4:52 PM, Thomas Wetmore <email@hidden> wrote:
> I hope someone can put me straight. I created a vanilla Cocoa App. I deleted the window from the MainMenu.xib and created a MainWindow.xib with essentially an identical window (no views).
>
> I created a MainWindowController with one overriding method, init, see below. In the app delegate's applicationDidFinishLaunching method I create the main window controller and attempt to show the main window. If I breakpoint just after the [mainController showWindow: nil] method I can see the proper user interface with the main menu and main window. However, when I let the program run the window immediately disappears. As none of my code runs after that point I'm at a bit of a loss discovering what makes the window go away.
>
> What am I doing (or not doing) that causes the main window to close or become invisible? The code is below.
>
> Thanks,
>
> Tom Wetmore
>
> AppDelegate.h:
> --------------
> @interface AppDelegate : NSObject <NSApplicationDelegate>
> @end
>
> AppDelegate.m:
> --------------
> #import "AppDelegate.h"
> #import "MainWindowController.h"
>
> @implementation AppDelegate
>
> - (void) applicationDidFinishLaunching: (NSNotification*) aNotification {
>     MainWindowController* mainController = [[MainWindowController alloc] init];
>     [mainController window]; // force controller to load nib.
>     [mainController showWindow: nil];  // show window -- which promptly disappears
> }
>
> @end
>
>
> MainWindowController.h:
> -----------------------
> @interface MainWindowController : NSWindowController
> @end
>
> MainWindowController.m:
> -----------------------
> #import "MainWindowController.h"
>
> @implementation MainWindowController
>
> - (id) init { return [super initWithWindowNibName: @"MainWindow"]; }
>
> @end
>
>
> _______________________________________________
>
> Cocoa-dev mailing list (email@hidden)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Main Window Disappears when Loaded from Separate NIB File
      • From: Thomas Wetmore <email@hidden>
References: 
 >Main Window Disappears when Loaded from Separate NIB File (From: Thomas Wetmore <email@hidden>)

  • Prev by Date: Main Window Disappears when Loaded from Separate NIB File
  • Next by Date: Re: Main Window Disappears when Loaded from Separate NIB File
  • Previous by thread: Main Window Disappears when Loaded from Separate NIB File
  • Next by thread: Re: Main Window Disappears when Loaded from Separate NIB File
  • Index(es):
    • Date
    • Thread