Re: handleGetURLEvent getting called after applicationDidFinishLaunching
Re: handleGetURLEvent getting called after applicationDidFinishLaunching
- Subject: Re: handleGetURLEvent getting called after applicationDidFinishLaunching
- From: Jerry Krinock <email@hidden>
- Date: Tue, 20 Aug 2013 12:37:47 -0700
On 2013 Aug 20, at 11:38, Bradley O'Hearne <email@hidden> wrote:
> So far, this problem seems isolated to Snow Leopard, I have not seen it on Lion or Mountain Lion. Also, the problem is intermittent [and much more] …
Brad, you probably know more about this problem than anyone in the world today. For issues with ancient versions of the OS, the smart strategy is: Patch It and Move On. Even if there were an Apple engineer or two that worked on this behavior three years ago, they are no doubt totally consumed with iOS 8 or whatever comes after Mac OS X 10.9.
> 1. Is there any guaranteed invocation order of these methods, or is it completely random?
Anything you can't find in the documentation is not guaranteed. Take the easy answer. Just assume that it is random. This way you're covered if it changes again in Mac OS X 10.9 or beyond.
> I cannot think of any scenario where you'd want to process the URL launching event *after* the callback which signifies app launch completion. That just seems wrong.
It could be, but exactly analogous behavior occurs when an app is launched by double-clicking a document in Finder: -[NSDocumentController openDocumentWithContentsOfURL:display:error: runs *before* -applicationDidFinishLaunching. But when an app is launched by an AppleScript 'open' command, -applicationDidFinishLaunching runs first.
> when the applicationDidFinishLaunching method is invoked first, the app fails, because it doesn't have the launch URL which has information needed to run the app
You need to change your design so it works either way. Move any code that requires the launch URL out of -applicationDidFinishLaunching. It probably belongs in some derivative of -handleGetURLEvent:withReplyEvent:. If there is code that needs to be done in -applicationDidFinishLaunching before you can handle the URL, write a -startUp method and put this code in -startUp, and invoke it within both methods. Use a BOOL isStartedUp to prevent it from running twice. You're done!
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden