2

I am all in favor of lazy instantiation of objects only once they are needed, especially with heavy ones like NSWindows. Unfortunately though I am using a WebKit view and need a way to preload a page (which can take up to 10) seconds, so I would like to kick off the view hierarchy initialization as soon as the app launches. I am building a task bar application so no windows are visible at startup.

My first instinct is a quick "hide and show" but there must be a better way to force a window to unarchive itself and call its awakeFromNib and windowDidLoad methods?

lmirosevic
  • 15,787
  • 13
  • 70
  • 116

1 Answers1

2

If you're using an NSWindowController to manage the window, you can call the window controller's -window method to cause it to load the window without showing it. Like so:

// Window is not loaded
[windowController window];
// Window is now loaded but not on screen
[windowController showWindow:nil];
// Window is now visible
Andrew Madsen
  • 21,309
  • 5
  • 56
  • 97