I have a main message loop. I'm looking for a way to check if the event is an AppleEvent and if it's Event Class is of 'MyClass' then do something. I've looked in NSEvent reference and was lost not finding what i need. Please can someone suggest an approach?
while (!shutdown_now_)
{
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
NSEvent *event = [NSApp nextEventMatchingMask:NSAnyEventMask
untilDate:[NSDate distantFuture]
inMode:NSDefaultRunLoopMode
dequeue:YES];
//if event is AppleEvent AND event class is <MyEventClass> then do something
if (event) [NSApp sendEvent:event];
[pool drain];
}
You cannot get an Apple Event via
NSEventin your loop like that.Because
NSEventjust doesn't cover it.Documentation says
You can find some more information in
NSApplicationdocumentationInstead you can use the
NSAppleEventManagerclass to register your own Apple event handlers with following method