NSDocument App: prevent a default behavior

I have an NSDocument-based application whose documents are not exactly "light-weight". Initializing a new document requires some up-front configuration choices by the user (like starting a new project in Xcode).


By default, when my app starts up it opens a document window with a blank document, and if the Dock icon is clicked when the application does not have a document open, it does the same... effectively creating a blank document in an invalid state. From a user perspective, this isn't appropriate behavior, as starting a new project document is not something done frequently (again, similar to Xcode).


Where can I hook into in the document/window controller/app lifecycle to prevent this behavior?


(edited to fix formatting the forum software munged)

Accepted Reply

This behavior is controlled by optional methods in your application delegate. In particular, you need to implement *both* of these:


applicationShouldHandleReopen(_:hasVisibleWindows:)

applicationShouldOpenUntitledFile(_:)

Replies

This behavior is controlled by optional methods in your application delegate. In particular, you need to implement *both* of these:


applicationShouldHandleReopen(_:hasVisibleWindows:)

applicationShouldOpenUntitledFile(_:)

Perfect. That did it. Thanks!