If you have code that needs to happen first/once at start, maybe you can try putting it in awakeFromNib.
Also, I think launching apps via NSWorkspace can be a little more robust than apple events, when possible. On Aug 20, 2013, at 3:00 PM, cocoa-dev-requ...@lists.apple.com wrote: > > Message: 6 > Date: Tue, 20 Aug 2013 11:38:52 -0700 > From: "Bradley O'Hearne" <br...@bighillsoftware.com> > To: List Developer Cocoa <cocoa-dev@lists.apple.com> > Subject: handleGetURLEvent getting called after > applicationDidFinishLaunching > Message-ID: <fdf86586-4fc5-4c20-8edb-93b9530cc...@bighillsoftware.com> > Content-Type: text/plain; charset=windows-1252 > > Hello…. > > I have a Mac app that is launched via a URL handler that is installed. The > launch services / configuration setup of the URL handler is fine, app > launches just as expected. However, I am seeing an intermittent problem where > the URL handling method: > > - (void)handleGetURLEvent:(NSAppleEventDescriptor *)event > withReplyEvent:(NSAppleEventDescriptor *)replyEvent; > > is invoked after the app delegate method: > > - (void)applicationDidFinishLaunching:(NSNotification *)aNotification; > > Normally, handleGetURLEvent is invoked first, which is important, because the > implementation of that method is usually needing to capture the URL used to > launch it, for later processing. That is exactly my case, and 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. > > So far, this problem seems isolated to Snow Leopard, I have not seen it on > Lion or Mountain Lion. Also, the problem is intermittent -- it works just > fine most of the time, even on the same machine where the problem > occasionally occurs. My questions: > > 1. Is there any guaranteed invocation order of these methods, or is it > completely random? 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. > > 2. Assuming that the answer to 1 is that there IS an expected invocation > order, then what could possibly cause this problem? This smells an awful lot > like something to do with unexpected results of thread scheduling in the OS > (not in the app, I'm creating no threads at all). > > If anyone has any thoughts or ideas, I'd greatly appreciate it. Even if any > of you have a similar use-case of an app with a URL handler that has to grab > that URL before doing anything in your app, sharing your experience might > help. > > Thanks, > > Brad > > > > > ------------------------------ > > _______________________________________________ > > Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) > > Do not post admin requests or moderator comments to the list. > Contact the moderators at cocoa-dev-admins (at) lists.apple.com > > https://lists.apple.com/mailman/listinfo/cocoa-dev > > > End of Cocoa-dev Digest, Vol 10, Issue 522 > ****************************************** _______________________________________________ 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