Re: Is there a more efficient way to get the first 4 bytes off a NSInputStream to compare
Re: Is there a more efficient way to get the first 4 bytes off a NSInputStream to compare
- Subject: Re: Is there a more efficient way to get the first 4 bytes off a NSInputStream to compare
- From: Jean-Daniel Dupas <email@hidden>
- Date: Tue, 27 Jan 2009 09:47:45 +0100
Le 27 janv. 09 à 06:28, Graham Cox a écrit :
On 27 Jan 2009, at 4:17 pm, Adam Venturella wrote:
Thanks! I knew I was doing to many steps!
uint key = *(uint*)&buffer;
You will also need to consider byte-ordering if your app or the data
could be used on different architectures. If for example your input
data is known to be big-endian, you'll probably want to do this:
uint key = NSSwapBigIntToHost( *(uint*)&buffer );
Or without the cast:
uint key = OSReadBigInt32(buffer, 0)
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden