質問

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?

役に立ちましたか?

解決

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.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top