0
votes

I have an app on OS X 10.10 which uses a storyboard. I cannot figure out how to prevent the main window from showing at launch.

I have the 'Visible At Launch' checkbox on the window unchecked.

I looked at a backtrace...

2015-02-03 19:50:19.714 Itsycal2[20485:620948] -[MyApp showWindow:]: caller: 1   AppKit  0x00007fff8bee4724 NSApplicationMain + 1080

...and it seems that NSApplicationMain is calling -showWindow: on my window controller?

The only way I can prevent the window from showing at launch is by overriding -showWindow: and not calling super. But now I've gutted -showWindow: and I don't want that.

How do I prevent NSApplicationMain from calling -showWindow: at launch?

1

1 Answers

2
votes

Under the HIG, all mac apps are required to show a window when the user clicks on the app icon, unless there is already a window open — then that one will be brought to the front.

Your app should show a window when showWindow is called. But if you really don't w ant to, then overriding showWindow: to do nothing (don't call super) is the correct approach.

The app icon being clicked (or your app being launched in some other way) is triggering a showWindow: event to be sent down the responder chain. Your window controller is in the "responder chain" and has a showWindow: method so it will be executed.

Alternatively, move your window controller out of the responder chain. Is it the app delegate? Perhaps your app delegate shouldn't be a subclass of NSWindowController. Make it subclass NSObject instead, then it won't have a showWindow: method. You can still have it be a controller with some windows, even if it doesn't subclass NSWindowController.

You can't stop the event from being triggered. You can only choose to ignore it.