1 #import <Cocoa/Cocoa.h>
2 #import <Foundation/Foundation.h>
7 AUTOFRAMEWORK(Foundation)
10 @interface appdelegate : NSObject<NSApplicationDelegate> @end
15 [NSApplication sharedApplication];
16 NSObject<NSApplicationDelegate> *delegate = [appdelegate new];
17 [NSApp setDelegate:delegate];
19 NSAppleEventManager *appleEventManager = [NSAppleEventManager sharedAppleEventManager]; /* Register a call-back for URL Events */
20 [appleEventManager setEventHandler:delegate andSelector:@selector(handleGetURLEvent:withReplyEvent:)
21 forEventClass:kInternetEventClass andEventID:kAEGetURL];
26 @implementation appdelegate
27 - (void)application:(id)arg openFiles:(NSArray*)file
34 s = [file objectAtIndex:i];
35 print("%s\n", [s UTF8String]);
37 [NSApp terminate:self];
40 - (void)handleGetURLEvent:(NSAppleEventDescriptor *)event withReplyEvent:(NSAppleEventDescriptor *)replyEvent
42 NSString* url = [[event descriptorForKeyword:keyDirectObject] stringValue];
43 print("%s\n", [url UTF8String] + (sizeof("plumb:") - 1));
44 [NSApp terminate:self];