Thanks for your help :) I want to show the sheet "when the app launches", meaning specifically when its main window first shows after launching (it's a single window app).
Since I want to present my welcome as a sheet, I need a window in which to show it, so I've tried:
calling showWelcome from inside the main ViewController (as provided by the "Main" storyboard in Xcode's default app template), both in viewDidLoad (crashes) and in viewDidAppear (shows the sheet again every time the app becomes visible).
from inside applicationDidFinishLaunching — doesn't work as it seems NSApplication.shared.mainWindow is not available yet at this point. Anyway as far as I can see, NSApplication.shared.mainWindow isn't great for this purpose because the user might minimise the app after launching it, but before its main window shows.
I was thinking there must be a nice place in the launch lifecycle for me to call showWelcome. I was looking for somewhere that fires "once the app has launched and we have the main window to work with". I'm starting to think I will just have to put it in the main window's content view controller's viewDidAppear, and maintain an "isFirstAppearance" boolean or some such.
Topic:
UI Frameworks
SubTopic:
AppKit
Tags: