Mac上的自定义URL类型Objective-C [英] Custom URL Types on Mac Objective-C

查看:407
本文介绍了Mac上的自定义URL类型Objective-C的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何创建自定义网址类型,我可以使用传入应用的数据执行操作。
我试过这个没有运气:

How can I create custom URL types that I can perform an action with the data passed into the app. I've tried this with no luck:

- (void)handleURLEvent:(NSAppleEventDescriptor*)event withReplyEvent:(NSAppleEventDescriptor*)replyEvent


推荐答案

您必须指定一个或应用程序属性列表文件(或XCode目标编辑器)中CFBundleURLTypes字典的更多键。

You have to specify one or more keys for the CFBundleURLTypes dictionary in your app's property list file (or in XCode target editor).

然后在您的应用程序委托 applicationWillFinishLaunching 写类似

Then in your app delegate applicationWillFinishLaunching write something like

NSAppleEventManager *appleEventManager = [NSAppleEventManager sharedAppleEventManager];
[appleEventManager setEventHandler:self andSelector:@selector(handleGetURLEvent:withReplyEvent:) forEventClass:kInternetEventClass andEventID:kAEGetURL];

这篇关于Mac上的自定义URL类型Objective-C的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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