Re: Extracting double or float from an NSAppleEventDescriptor
Re: Extracting double or float from an NSAppleEventDescriptor
- Subject: Re: Extracting double or float from an NSAppleEventDescriptor
- From: Ken Ferry <email@hidden>
- Date: Sat, 3 Jul 2004 18:16:11 -0400
This'll work.
double *aDouble;
[[[aDescriptor coerceToDescriptorType:typeIEEE64BitFloatingPoint]
data] getBytes:&aDouble];
I have a little suite of helpers at
<
http://homepage.mac.com/kenferry/software.html#KFAppleScript> that has
a lot of convenience methods for doing conversions.
-Ken
On Jul 3, 2004, at 5:58 PM, Ken Tozier wrote:
I'm sure this is an easy one, but I'm having a little trouble
extracting double and float values from NSAppleEventDescriptors.
They don't have convenience methods for either of these types and my
attempts aren't working.
Here's what I've tried:
Assume aDescriptor contains a double.
double aDouble = *(double*)[[aDescriptor data] bytes];
Is there a less squirrely way to coerce the value of an NSData object
to a float or double? NSNumber doesn't seem to have any initializers
that support them.
Thanks
Ken
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.