Frage

Recently, a document that was saved caused a crash whenever I would start my app. Is there a way to prevent a doc-based app from opening any document, including a new empty or the last active document(s)? I'd like to do that not by using OSX functionality (outside the scope of my app), but within my program.

I would think that this should be done through the NSDocumentController somehow, but I cannot figure it out and have had no luck finding answers elsewhere.

So, how to tell an OSX app (through NSDocumentController) to not open any documents at startup?

War es hilfreich?

Lösung

You're probably looking for functionality that is defined in the NSApplicationDelegate-protocol. Specifically the following two methods give you some control over what happens on app start:

- (BOOL)applicationShouldHandleReopen:(NSApplication *)theApplication hasVisibleWindows:(BOOL)flag
- (BOOL)applicationShouldOpenUntitledFile:(NSApplication *)sender

See the documentation for more.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top