Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Don't open an untitled file if OS X Lion will reopen a document

Tags:

cocoa

osx-lion

I've got a Core Data Document Based App (OS X) that opens an untitled document if the user hasn't specified a document to open on startup. Now that Lion reopens documents on launch, I need to know how to prevent this untitled document from opening if there are documents to be reopened from the last time the program ran.

Previously, I did some checking in

- (BOOL) applicationShouldOpenUntitledFile: (NSApplication *) sender

and returned YES or NO appropriately. What should I check now to prevent an untitled document from being opened when there are documents to restore?

like image 687
Jeff Hellman Avatar asked Nov 04 '22 15:11

Jeff Hellman


1 Answers

From Lion's release notes:

As part of the restorable windows feature, the application delegate may not be asked to create an Untitled window at launch in some circumstances. This was found to cause crashes in certain apps, so these apps will maintain 10.6 behavior of more often opening Untitled windows. When these apps are recompiled on 10.7, they will acquire the 10.7 behavior. For maximum compatibility, do not depend on being asked to create an Untitled window at launch.

Basically, they're saying "it may not work and we're not going to say why, so it's best not to rely on it at all."

like image 153
Joshua Nozzi Avatar answered Nov 16 '22 10:11

Joshua Nozzi