> On 11 Nov 2015, at 22:34, Shane Stanley <sstan...@myriad-com.com.au> wrote: > > On 12 Nov 2015, at 4:29 AM, Dave <d...@looktowindward.com> wrote: >> >> I restarted my Mac and and added as string on the handler definition and it >> started working (not sure which of these helped): > > The "as string" did it. Passing from Objective-C to AppleScript uses lazy > conversion; it doesn't happen unless you ask for it.
Thanks, I’ve added the “as xxxx” to all my parameters which has the added bonus greatly improves the readably when calling from Objective-C. >> >> But now I have another problem with types/classes on the: >> >> set kMessageID of myDictionary to (the id of myMessage >> as string) >> set kMessageClass of myDictionary to (the class of >> myMessage as string) >> >> When I look at the returned dictionary I see: >> >> kMessageClass = "\U00abclass outm\U00bb"; >> kMessageID = 540; >> >> Which are not of type NSString which is what I expected. However, if I run >> the script in the Script Editor I get the String Equivalents: >> >> kMessageID:"540”, >> kMessageClass:"outgoing message" > > You're expecting roughly the equivalent of an enum being returned as a string > rather than an int in Objective-C, or a constant necessarily matching what it > represents. Script Editor has the dictionary loaded so it can do the > conversion, but a running app doesn't, so it converts the underlying code as > best it can. > > You need to test the options and build your own string: > > if class of myMessage is outgoing message then > set kMessageClass of myDictionary to "outgoing message" > … Yes, I came to the same conclusion but did it a slightly different way, if you do this: set myClass to the class of myMessage as string This produces a string something like this: "<<class>> outm” not sure what the <<>> character(s) are? They are not regular greater/less than chars. Then in Objective-C I setup a Dictionary at App Startup with contains mappings, e.g. “outm" == “outgoingMessage”. All the Best Dave _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com