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: Fri, 23 Aug 2013 07:35:06 +0200
On Aug 22, 2013, at 18:29, Bradley O'Hearne <email@hidden> wrote:
> On Aug 22, 2013, at 9:00 AM, Kyle Sluder <email@hidden> wrote:
>> On Aug 22, 2013, at 8:00 AM, Jens Alfke <email@hidden> wrote:
>>> On Aug 22, 2013, at 1:34 AM, Uli Kusterer <email@hidden> wrote:
>>>
>>>> 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.
>>>
>>> Nope. (And not to pull rank, but I was on the AppleEvents/AppleScript team at the time we figured this stuff out [1991] and added the seemingly-useless ‘oapp’ event in response to developer complaints.)
>>>
> While this may well be true that there is no sequence, this one developer's view is that while an app should be able to respond to any downstream open event while running, it makes no sense to arbitrarily deliver or delay information about how an app was launched to the app sometime after the launch loading is complete. That effectively suggests having to poll and eventually timeout in order to get the initial UI display right, which seems really unnecessary if the proper protocol is just to tell an app when loading how it was launched.
Sorry, I misunderstood your original post then. Of course, if you’re looking at the kAEOpenApplication Apple Event, the second case is ‘more correct’, but NSApplicationDidFinishLaunching is not equivalent to kAEOpenApplication, and the OP didn’t ask about it either*. NSApplicationDidFinishLaunching is a notification sent by the framework to indicate the event loop of an application has been set up. kAEOpenApplication on the other hand is an event sent by the system to indicate an application has been opened without documents.
The OP’s problem is choosing the wrong trigger. If you look at the docs (https://developer.apple.com/library/mac/documentation/cocoa/reference/NSApplicationDelegate_Protocol/Reference/Reference.html#//apple_ref/occ/intfm/NSApplicationDelegate/applicationDidFinishLaunching:), it even explicitly says:
> If you want to perform initialization before any files are opened, implement the applicationWillFinishLaunching: method in your delegate, which is called before application:openFile:.)
Though I still think it’s safer to NOT rely on this order, and instead perform the initialization in a lazy-loading accessor, so that it is guaranteed the first one who needs the information (and requests it using the accessor) causes it to be loaded, no matter what spot the code is moved to.
Cheers,
-- Uli Kusterer
“The Witnesses of TeachText are everywhere...”
http://zathras.de
*) For completeness’ sake and people searching the list archives: The equivalent to kAEOpenApplication in AppKit (apart from installing an Apple Event handler for that event directly) is probably the applicationOpenUntitledFile: delegate method. However, that also gets called for ‘rapp’ events (kAEReopenApplication, i.e. app has been requested to launch w/o documents while already running e.g. by Finder double-click or dock icon click).
_______________________________________________
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