Skip navigation.
 
mlNSAppleEventDescriptor - getting a double (and other animals)
FROM : Luke Evans
DATE : Tue Jan 22 05:46:48 2008

I wish to allow my scripting interface to accept 'any' for a 
property.  I see that this is handled in Cocoa by the relevant method 
being sent an object of type NSAppleEventDescriptor, and I have 
implemented the fairly straightforward and obvious code to handle the 
types string, int32 and boolean (these all being available on 
NSAppleEventDescriptor itself).  Now, I need to implement handlers for 
some other types (doubles, dates).  This is clearly where things kick 
up a gear in terms of what is required to handle them properly, and my 
browsing of docs so far (particularly the Cocoa Scripting Guide) has 
not turned up the recommended way of coercing these 
NSAppleEventDescriptors to appropriate objects (NSNumber, NSDate...). 
I could coerce everything through a string with what I have now, but I 
think that would be a tad naughty.

I see there's an NSScriptCoercionHandler, and I've tried messing with 
it (i.e. convert a numeric NSAppleEventDescriptor to an NSNumber), but 
given the fact it seems to hand the original object right back, I 
imagine that I'm misunderstanding its use (...there's not a great deal 
of documentation on this class).

What is the proper way to unpack NSAppleEventDescriptors when I'm 
after simple values like doubles and dates?  (Maybe I'll deal with 
lists later, but I think I can already see how lists work).

-- Lwe

Related mailsAuthorDate
mlNSAppleEventDescriptor - getting a double (and other animals) Luke Evans Jan 22, 05:46
mlRe: NSAppleEventDescriptor - getting a double (and other animals) has Jan 22, 18:59