On May 6, 2014, at 11:23 , Mills, Steve <smi...@makemusic.com> wrote:

> I'm looking at a crash log for our app that shows our app is initting. During 
> init ([NSApplication finishLaunching]) we discover a problem and put up a 
> modal dialog using [NSApplication runModalForWindow:]. During this modal run 
> loop, something has decided that it would be a great time to handle the 
> reopen event, so [NSDocumentController 
> reopenDocumentForURL:withContentsOfURL:display:completionHandler:] is called 
> and we open a document while the modal dialog is up, and before we've totally 
> finished handling [NSApplication finishLaunching].

It sounds like you’re Doing It Wrong™. Well, sorta j/k, but seriously you’re 
overriding ‘finishLaunching’?

From the NSApplicationDelegate protocol documentation:

> "applicationDidFinishLaunching:
> 
> "Delegates can implement this method to perform further initialization. This 
> method is called after the application’s main run loop has been started but 
> before it has processed any events. If the application was launched by the 
> user opening a file, the delegate’s application:openFile: method is called 
> before this method. If you want to perform initialization before any files 
> are opened, implement the applicationWillFinishLaunching: method in your 
> delegate, which is called before application:openFile:.)”

So documents may be opened between the issuing of the two notifications 
(wiil/didFinishLaunching). Both of those notifications, I would assume, are 
posted in ‘finishLaunching’, so your concept of “totally finished handling 
[NSApplication finishLaunching]” sounds flawed. In particular, putting up a 
modal dialog before invoking [super finishLaunching] — if that’s what you do — 
sounds like a bad idea.

Why aren’t you doing the initialization in the delegate methods?

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to