Custom URL Types on Mac Objective-C

穿精又带淫゛_ 提交于 2019-12-11 11:41:28

问题


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

回答1:


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];



回答2:


  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.



来源:https://stackoverflow.com/questions/12567028/custom-url-types-on-mac-objective-c

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!