Custom URL Types on Mac Objective-C

2019-08-05 09:31发布

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

2条回答
孤傲高冷的网名
2楼-- · 2019-08-05 09:56

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

Then in your app delegate applicationWillFinishLaunching write something like

NSAppleEventManager *appleEventManager = [NSAppleEventManager sharedAppleEventManager];
[appleEventManager setEventHandler:self andSelector:@selector(handleGetURLEvent:withReplyEvent:) forEventClass:kInternetEventClass andEventID:kAEGetURL];
查看更多
老娘就宠你
3楼-- · 2019-08-05 09:57
  1. Select your project in the left pane.
  2. Select your target in the list.
  3. Go to the Info tab.
  4. Add new URLs under URL Types.

enter image description here

查看更多
登录 后发表回答