我将这些行添加到我的Info.pList中:
<key>CFBundleURLTypes</key><array> <dict> <key>CFBundleURLname</key> <string>MyApp URL</string> <key>CFBundleURLSchemes</key> <array> <string>myscheme</string> </array> </dict></array>
在我的应用程序委托中,我在ApplicationDIDFinishedLaunching中安装事件处理程序:
NSAppleEventManager *appleEventManager = [NSAppleEventManager sharedAppleEventManager];[appleEventManager setEventHandler:self andSelector:@selector(handleGetURLEvent:withReplyEvent:) forEventClass:kInternetEventClass andEventID:kAEGetURL];
但是当我点击带有URL的链接时,不会调用该方法. “myscheme://测试”
- (voID)handleGetURLEvent:(NSAppleEventDescriptor *)event withReplyEvent:(NSAppleEventDescriptor *)replyEvent { // Extract the URL from the Apple event and handle it here. Nsstring* url = [[event paramDescriptorForKeyword:keyDirectObject] stringValue]; NSLog(@"%@",url);}
我错过了什么?
解决方法 听起来你可能需要清理你的项目.当Xcode构建应用程序时,有时启动服务数据库(处理URL关联)无法正确更新.清理项目应该完全删除构建的应用程序,因此下次构建项目时,会在更新Launch Services数据库的过程中从头开始创建项目.您可能还想尝试将应用程序复制到/ Applications文件夹中,这应该使Launch Services重新解析应用程序的Info.pList文件.
您可以通过在终端中运行以下命令来强制启动服务来重建其数据库:
/System/library/Frameworks/applicationservices.framework/Frameworks/LaunchServices.framework/Support/lsregister -kill -r -domain local -domain system -domain user总结
以上是内存溢出为你收集整理的cocoa – handleGetURLEvent不会被调用全部内容,希望文章能够帮你解决cocoa – handleGetURLEvent不会被调用所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)