3
我註冊使用NSAppleEventManager蘋果事件處理程序:回覆的蘋果事件在可可
[[NSAppleEventManager sharedAppleEventManager]
setEventHandler:self andSelector:@selector(handleGetURLEvent:withReplyEvent:)
forEventClass:kInternetEventClass andEventID:kAEGetURL];
我的處理方法,當然,對事件進行接收和回覆事件:
- (void) handleGetURLEvent:(NSAppleEventDescriptor *)event withReplyEvent:(NSAppleEventDescriptor *)replyEvent {
//Open this URL; reply if we can't
}
因此,如果我需要回復一個錯誤,表明我以某種方式打開此URL失敗,那麼我應該如何使用replyEvent
來做到這一點?
但如何發送此回覆? – jimwan 2017-02-21 05:45:48
@ jimwan:可可自動發回。它向你提供了一個物件供你填寫細節。 (實際上,Cocoa只是作爲一個介於兩者之間的底層Apple底層事件API爲Cocoa提供了回覆事件對象並自動發回。) – 2017-02-21 23:06:08