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: Adam Venturella <email@hidden>
- Date: Mon, 26 Jan 2009 21:17:35 -0800
Thanks! I knew I was doing to many steps!
On Mon, Jan 26, 2009 at 8:44 PM, Graham Cox <email@hidden> wrote:
>
> On 27 Jan 2009, at 2:09 pm, Adam Venturella wrote:
>
>> NSData * d = [NSData dataWithBytes:buffer length:sizeof(buffer)];
>> uint * key = (uint *) malloc(sizeof(uint));
>> [d getBytes:key length:sizeof(uint)];
>
>
> uint key;
>
> [d getBytes:&key length:sizeof(uint)];
>
> but since you have merely wrapped <buffer> in NSData, you already have the
> buffer, so:
>
> uint key = *(uint*)&buffer;
>
> is also exactly the same, you don't need the NSData at all (at least as far
> as this bit goes).
>
> --Graham
>
>
>
>
>
_______________________________________________
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