get url event on app open in objective c (Mac OSX)

筅森魡賤 提交于 2019-12-30 10:47:25

问题


I'm writing a very lightweight app for OSX 10.6+ which will respond to a user clicking on a URL, pass that URL to another application via TCP and then exit.

So far it has registered fine to launch when a user clicks the custom url scheme. However the event seems to get lost if the app is not already running. So the users clicks the link, the app loads, but nothing happens. Once the app is running, if the user clicks the link then it grabs the event and processes it as normal.

What do I need to do to catch that initial event that causes the app to open in the first place?

Currently I'm creating the NSAppleEventManager in the applicationDidFinishLaunching method, and this works for all events created AFTER the initial load, just not for the one that actually opened the app itself.

Any advice would be brilliant!

Thanks!


回答1:


You should be creating your AppleEvent handlers in -applicationWillFinishLaunching: instead.

The idea is to have your handlers ready to go before your application begins processing AppleEvents.



来源:https://stackoverflow.com/questions/12919502/get-url-event-on-app-open-in-objective-c-mac-osx

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!