我的问题与这个问题相同,但它已经有一段时间没有更新了,而且自从被问到 Swift 已经发生了很大的变化,所以答案可能需要刷新。我想要做的就是捕获用于打开我的可可应用程序的 url,但代码永远不会在我的处理程序函数中执行。当我通过自定义 url 方案启动我的应用程序时,在 Console.app 中抛出错误。以下是错误:
-[MyApp.AppDelegate handleGetURLEvent:replyEvent:]: unrecognized selector sent to instance 0x60c0000039b0
-[MyApp.AppDelegate handleGetURLEvent:replyEvent:]: unrecognized selector sent to instance 0x60c0000039b0
OSErr AERemoveEventHandler(AEEventClass, AEEventID, AEEventHandlerUPP, Boolean)(spec,phac handler=0x7fff576b7f15 isSys=YES) err=0/noErr
-[MyApp.AppDelegate handleGetURLEvent:replyEvent:]: unrecognized selector sent to instance 0x60c0000039b0
-[MyApp.AppDelegate handleGetURLEvent:replyEvent:]: unrecognized selector sent to instance 0x60c0000039b0
OSErr AERemoveEventHandler(AEEventClass, AEEventID, AEEventHandlerUPP, Boolean)(GURL,GURL handler=0x7fff5661d680 isSys=YES) err=0/noErr
LSExceptions shared instance invalidated for timeout.
Run Code Online (Sandbox Code Playgroud)
而我的裸骨应用程序:
创建一个名为 MyApp 的新 Cocoa 应用程序。在 Info > URL Types 中,在 Identifier 字段和blue(例如)URL Schemes …