• 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: NSData to long
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSData to long


  • Subject: Re: NSData to long
  • From: Shawn Erickson <email@hidden>
  • Date: Tue, 8 Apr 2003 13:28:23 -0700

On Tuesday, April 8, 2003, at 07:41 AM, David Blanton wrote:

On 4/8/03 3:28 AM, "Nathan Day" <email@hidden> wrote:

Use the method bytes to get a pointer to the data and just cast it. Or
you could use the method getBytes.

long int theLong;
[theData getBytes:(void*)&theLongInt length:sizeof(long int)];


Thank you Nathan and all others who commented. I have implemented the
above.

They above works fine but make sure you (you all) understand that you are making assumptions about the endianness (byte order) of the data as well as the size of "long int". If your application has the chance of using data from systems with different endianness and/or size for "long int" I would use a safer method, one that gets you the same results regardless of the above issues.

Remember Mac OS X _could_ be running on 64 bit systems and even on systems with a differing byte ordering in the not so distant future.

-Shawn
_______________________________________________
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: 
 >Re: NSData to long (From: David Blanton <email@hidden>)

  • Prev by Date: Re: Reading a legacy file format
  • Next by Date: write dictionary to file
  • Previous by thread: Re: NSData to long
  • Next by thread: Re: NSData to long
  • Index(es):
    • Date
    • Thread