I'm registering an Apple Event handler using NSAppleEventManager:
[[NSAppleEventManager sharedAppleEventManager]
setEventHandler:self andSelector:@selector(handleGetURLEvent:withReplyEvent:)
forEventClass:kInternetEventClass andEventID:kAEGetURL];
My handler method will, of course, receive the event and a reply event:
- (void) handleGetURLEvent:(NSAppleEventDescriptor *)event withReplyEvent:(NSAppleEventDescriptor *)replyEvent {
//Open this URL; reply if we can't
}
So, if I need to reply with an error, indicating that I failed in some way to open this URL, how should I use the replyEvent
to do that?
I have translated the following from the old-style C procedural API described in Apple's legacy document "Apple Events Programming Guide" to Cocoa:
if ([replyEvent descriptorType] != typeNull)
{
[replyEvent setParamDescriptor:[NSAppleEventDescriptor descriptorWithInt32:someStatusCode] forKeyword:keyErrorNumber];
[replyEvent setParamDescriptor:[NSAppleEventDescriptor descriptorWithString:someErrorString] forKeyword:keyErrorString];
}
See "Returning Error Information" in the "Apple Events Programming Guide" (in the Legacy library).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With