Re: handleGetURLEvent getting called after applicationDidFinishLaunching
Re: handleGetURLEvent getting called after applicationDidFinishLaunching
- Subject: Re: handleGetURLEvent getting called after applicationDidFinishLaunching
- From: Uli Kusterer <email@hidden>
- Date: Thu, 22 Aug 2013 10:34:08 +0200
On Aug 22, 2013, at 1:08, Jens Alfke <email@hidden> wrote:
> Basically it sounds like the bug is that someone is doing (in pseudocode)
> app = app_for_url_scheme(url.scheme)
> launch_app(app)
> send_url_to_app(url)
> instead of the correct way:
> app = app_for_url_scheme(url.scheme)
> launch_app_with_url(app, url)
The notion of one of these being ‘more correct’ than the other is ridiculous. The second case is simply a performance optimization from the classic MacOS days that was carried over to OS X. Since a GURL Apple Event (which is what is used to send URLs to applications in both cases) can occur at any time, and your app may be already running or may need to be launched to be possible to send an Apple Event to it, you can never rely on a particular order.
If you need your data to be set up before the GURL Apple Event, write your code so it enforces that. E.g. by writing a lazy-loading getter for whatever data you currently load in applicationDidFinishLaunching:, and calling it in your GURL Apple Event. That decouples it from the (completely unrelated) notification.
Cheers,
-- Uli Kusterer
“The Witnesses of TeachText are everywhere...”
http://zathras.de
_______________________________________________
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