我有一个使用自定义URL方案在Swift中编写的Mac应用程序。获取用于启动OS X应用程序的初始URL
如果应用程序正在运行并从链接打开,则一切正常。但是,如果应用程序没有运行,那么应用程序无法打开正确的页面。
我注册的通知是这样的:
let eventManager = NSAppleEventManager.sharedAppleEventManager()
eventManager.setEventHandler(self, andSelector: "handleGetURLEvent:replyEvent:", forEventClass: AEEventClass(kInternetEventClass), andEventID: AEEventID(kAEGetURL))
我如何从最初推出的网址:
func applicationDidFinishLaunching(aNotification: NSNotification)
编辑1: 在我的应用程序委托我:
func handleGetURLEvent(event: NSAppleEventDescriptor?, replyEvent: NSAppleEventDescriptor?)
该函数被调用,并且在应用程序已经打开时工作,但是当应用程序关闭时无法工作。
我有一个功能,在解决它我的应用程序委托,但它没有正确触发。 –
你在哪里注册了你的'setEventHandler'? –
in func applicationDidFinishLaunching(aNotification:NSNotification) –