Is there a more efficient way to get the first 4 bytes off a NSInputStream to compare
Is there a more efficient way to get the first 4 bytes off a NSInputStream to compare
- Subject: 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 19:09:12 -0800
Here is what I am doing now.. I just feel like I have an extra step in
converting the buffer into NSData...malloc...free
uint sample = 0x04034b50;
uint8_t buffer[sizeof(uint)];
[inputStream open];
[inputStream read: buffer maxLength:sizeof(buffer)];
NSData * d = [NSData dataWithBytes:buffer length:sizeof(buffer)];
uint * key = (uint *) malloc(sizeof(uint));
[d getBytes:key length:sizeof(uint)];
[inputStream close];
NSLog(@"%u = %u", *key, sample);
free(key);
_______________________________________________
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