title: URL scheme - Qt and mac
body: <p>I'm trying to implement a custom URL scheme for my application. I've added the necessary lines for my Info.plist. After calling the specified url (eg.: myapp://) the application launches.</p>
  
  <p>If I want to handle the URL, I've found these steps:</p>
  
  <pre><code>@interface EventHandler : NSObject {
  }
  @end
  
  @implementation EventHandler
  - (id)init {
      self = [super init];
  
      if (self) {
          NSLog(@"eventHandler::init");
  
          NSNotificationCenter* defaultCenter = [NSNotificationCenter defaultCenter];
          [defaultCenter addObserver:self
                          selector:@selector(applicationDidFinishLaunching:)
  //                        name:NSApplicationWillFinishLaunchingNotification
            name:NSApplicationDidFinishLaunchingNotification
                          object:nil];
      }
      return self;
  }
  
  - (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
      NSAppleEventManager *appleEventManager = [NSAppleEventManager sharedAppleEventManager];
      [appleEventManager setEventHandler:self andSelector:@selector(handleGetURLEvent:withReplyEvent:) forEventClass:kInternetEventClass andEventID:kAEGetURL];
  }
  
  - (void)handleGetURLEvent:(NSAppleEventDescriptor *)event withReplyEvent:(NSAppleEventDescriptor *)replyEvent
  {
      NSString* url = [[event paramDescriptorForKeyword:keyDirectObject] stringValue];
      NSLog(@"%@", url);
  }
  
  @end
  </code></pre>
  
  <p>The above code is working if the application is running, but if the URL gets called and the application was terminated, the event is not caught. I think this is because this: NSApplicationDidFinishLaunchingNotification.
  Changing it to NSApplicationWillFinishLaunchingNotification causes that non events caught. Maybe Qt handles it before me, but I can't find a workaround for the problem.</p>