我有一个主消息循环。我正在寻找一种方法来检查事件是否是 AppleEvent 以及它的事件类是否属于“MyClass”然后做一些事情。我查看了 NSEvent 参考,但找不到我需要的东西。请问有人可以提出一种方法吗?
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];
}