I have an app that handles different kinds of apple events. I am developing an auxiliary app to test this first app (all in swift).
In my main app I have a handler function such as:
func handleAppleEvent(event : UnsafePointer?, reply : UnsafeMutablePointer?, refcon : Optional) -> OSErr {
//read apple event
....
return error
}
Where error is a variable that can be 0 if no error occured or any code depending on what has happened.
In my aux app I create an apple event pointing to the main app, an empty reply event and send it using the method AESendMessage
AESendMessage( &appleEvent,
&reply,
AESendMode(kAEWaitReply),
0)
I want to test it with correctly set appleEvents and wrongly set AppleEvents. No matter what kind of event I send, the result of AESendMessage is 0. I am sure that the return is non zero on the main app, since by debugginb goth apps at the same time this variable is correctly set to other values.
Therefore, either:
- I am not understanding how to retreive this error code
- There is somewhere where the information is lost
EDIT: When I send the events from AppleScripts the result codes are shown as I expect. (for ex. when a parameter is missing a "Some parameter is missing for «event ********»." error is shown with its related error code). I do not want to do the testing with AppleScripts since the information being sent is complex.
Can someone help me?
Thank you