• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Extracting double or float from an NSAppleEventDescriptor
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.


References: 
 >Extracting double or float from an NSAppleEventDescriptor (From: Ken Tozier <email@hidden>)

  • Prev by Date: Extracting double or float from an NSAppleEventDescriptor
  • Next by Date: Re: Misc questions
  • Previous by thread: Extracting double or float from an NSAppleEventDescriptor
  • Next by thread: Newbie: Cocoa App accessing SQL Server DB
  • Index(es):
    • Date
    • Thread