aboutsummaryrefslogtreecommitdiffstats
path: root/CopyMailto/AppDelegate.m
diff options
context:
space:
mode:
authorTeddy Wing2018-09-05 17:41:39 +0200
committerTeddy Wing2018-09-05 18:09:56 +0200
commit5aeed5af8334baad05159ca75e4d72e7179d70c8 (patch)
tree23891139ef367cc8b38c1847626b7ae082fe1f42 /CopyMailto/AppDelegate.m
parent69d948f117df445d1cb1060ebda9afd967a58f74 (diff)
downloadCopy-Mailto-5aeed5af8334baad05159ca75e4d72e7179d70c8.tar.bz2
Add URL Apple Event handling code
This untested code should allow the application to respond to a Launch Services URL to open the application. From Thomas Zoechling (https://stackoverflow.com/users/100848/thomas-zoechling) on Stack Overflow: https://stackoverflow.com/questions/1991072/how-to-handle-with-a-default-url-scheme/1991162#1991162
Diffstat (limited to 'CopyMailto/AppDelegate.m')
-rw-r--r--CopyMailto/AppDelegate.m15
1 files changed, 13 insertions, 2 deletions
diff --git a/CopyMailto/AppDelegate.m b/CopyMailto/AppDelegate.m
index 3ea136a..281d151 100644
--- a/CopyMailto/AppDelegate.m
+++ b/CopyMailto/AppDelegate.m
@@ -15,8 +15,12 @@
@implementation AppDelegate
-- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
- // Insert code here to initialize your application
+- (void)applicationWillFinishLaunching:(NSNotification *)aNotification {
+ [[NSAppleEventManager sharedAppleEventManager]
+ setEventHandler:self
+ andSelector:@selector(handleURLEvent:withReplyEvent:)
+ forEventClass:kInternetLocationMail
+ andEventID:kAEOpenApplication];
}
@@ -24,5 +28,12 @@
// Insert code here to tear down your application
}
+- (void)handleURLEvent:(NSAppleEventDescriptor *)event
+ withReplyEvent: (NSAppleEventDescriptor *)replyEvent
+{
+ NSString *url = [[event paramDescriptorForKeyword:keyDirectObject]
+ stringValue];
+ NSLog(@"%@", url);
+}
@end