在目标c(Mac OSX)中打开的应用上获取url事件 [英] get url event on app open in objective c (Mac OSX)

查看:152
本文介绍了在目标c(Mac OSX)中打开的应用上获取url事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为OSX 10.6+编写一个非常轻巧的应用程序,它将响应用户单击URL,然后将该URL通过TCP传递到另一个应用程序,然后退出.

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.

到目前为止,当用户单击自定义url方案时,它可以很好地启动.但是,如果该应用尚未运行,则该事件似乎会丢失.因此,用户单击链接,应用程序加载,但没有任何反应.应用运行后,如果用户单击链接,则它将捕获事件并按正常方式对其进行处理.

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?

当前,我正在applicationDidFinishLaunching方法中创建NSAppleEventManager,该方法适用于初始加载后创建的所有事件,而不是实际打开应用程序本身的事件.

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.

任何建议都会很棒!

谢谢!

推荐答案

您应该在-applicationWillFinishLaunching:中创建AppleEvent处理程序.

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

想法是让您的处理程序在应用程序开始处理AppleEvents之前准备就绪.

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

这篇关于在目标c(Mac OSX)中打开的应用上获取url事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆