俺様用メモ:独自のスキームを持つURLを開くアプリケーションを作る
NSApp delegateなんかで
- (void)applicationWillFinishLaunching:(NSNotification *)notification { [[NSAppleEventManager sharedAppleEventManager] setEventHandler:self andSelector:@selector(handleAppleEvent:withReplyEvent:) forEventClass:'GURL' andEventID:'GURL']; } -(void) handleAppleEvent:(NSAppleEventDescriptor*)event withReplyEvent:(NSAppleEventDescriptor*)replyEvent { AEEventClass eventClass = [event eventClass]; AEEventID eventID = [event eventID]; if (eventClass == 'GURL' && eventID == 'GURL') { NSString *URLString = [[event paramDescriptorForKeyword:keyDirectObject] stringValue]; [self openURLString:URLString]; } }
そしてinfo.plistで
<key>CFBundleURLTypes</key> <array> <dict> <key>CFBundleURLName</key> <string>jp.natori.Thousand.url</string> <key>CFBundleURLSchemes</key> <array> <string>thousand</string> </array> </dict> </array>
デフォルトアプリケーションの設定もしたほうがいいのかしら。ともかくこれでThousandはthousand://なURLを開くことが出来るようになった。