在您的应用程序委托的中
-applicationWillFinishLaunching:,执行以下操作:
[[NSAppleEventManager sharedAppleEventManager] setEventHandler:self andSelector:@selector(handleAppleEvent:withReplyEvent:) forEventClass:kInternetEventClass andEventID:kAEGetURL];
并且
handleAppleEvent:withReplyEvent:应如下所示:
- (void)handleAppleEvent:(NSAppleEventDescriptor *)event withReplyEvent:(NSAppleEventDescriptor *)replyEvent { NSString *urlString = [[event paramDescriptorForKeyword:keyDirectObject] stringValue]; // do something with the URL string}


