On 12 Nov 2015, at 4:29 AM, Dave <[email protected]> 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.
>
> 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"
...
--
Shane Stanley <[email protected]>
<www.macosxautomation.com/applescript/apps/>
_______________________________________________
Cocoa-dev mailing list ([email protected])
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 [email protected]