问题
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:
- Select your project in the left pane.
- Select your target in the list.
- Go to the Info tab.
- Add new URLs under URL Types.
来源:https://stackoverflow.com/questions/12567028/custom-url-types-on-mac-objective-c