• 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 and Primitives
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSData and Primitives


  • Subject: Re: NSData and Primitives
  • From: Buzz Andersen <email@hidden>
  • Date: Mon, 10 Jun 2002 08:58:29 -0600

All,
Thanks very much for your responses on this question--you have no idea how
helpful they are to a novice like myself!

For the benefit of posterity, Aram was right on with the endianness issue:
the file was little endian that was what was causing my weird results (i.e.
numbers in the billions where I was expecting hundreds).

Thanks again,
Buzz

on 6/9/02 7:22 PM, Aram Greenman at email@hidden wrote:

> On Sunday, June 9, 2002, at 04:46 PM, Buzz Andersen wrote:
>
> You can simplify this considerably:
>
>
> [[file readDataOfLength:sizeof(long)] getbytes:&number];
>
> but you should add this:
>
> number = NSSwapLittleLongToHost(number);
>
> or
>
> number = NSSwapBigLongToHost(number);
>
> depending if the file is little- or big-endian. Also, -[NSFileHandle
> readDataOfLength:] throws an exception on error, so you should catch
> that.
>
>>
>> Is this the best way to do it, or is there a better way using
>> Foundation or
>> Appkit classes? Is this even a reliable way of doing it (I'm kind of
>> having
>> trouble figuring out if this method is working properly--the results
>> don't
>> seem right to me).
>
> I bet the file is little-endian.
>
>
> a.
_______________________________________________
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 and Primitives (From: Aram Greenman <email@hidden>)

  • Prev by Date: Re: Small NSButton
  • Next by Date: Filter services
  • Previous by thread: Re: NSData and Primitives
  • Next by thread: Re: NSData and Primitives
  • Index(es):
    • Date
    • Thread