Re: NSData object
Re: NSData object
- Subject: Re: NSData object
- From: John Anderson <email@hidden>
- Date: Fri, 11 Apr 2003 04:09:36 -0400
On Friday, Apr 11, 2003, at 03:28 America/Detroit, Peter Karlsson wrote:
Dear Peter,
Try assigning your 2 bytes of data to a pair C type "int" buffers,
like so:
int buffer1, buffer2;
NSRange range;
range.location = 5;
range.length = 2;
[myData getBytes:&buffer1 range:range];
[myData getBytes:&buffer2 range:range];
Then use C "bitwise" OR operators to manipulate buffer1 and buffer2 to
get what you want, perhaps like so (you need check if this exactly
correct ):
buffer1 = buffer1 ^ buffer2;
Then, make myData2 with buffer1.
myData2 = [NSData dataWithBytesNoCopy:&buffer1 length:];
Truly yours,
John Anderson
I have a NSData object like this:
// code snippet
NSData *myData = [NSData dataWithContentsOfFile:thePath];
Now I want to read 2 bytes from this object (from offset 5 and 6).
These 2 bytes are in a nybble-ized format like this:
0000llll (offset 5 from start of myData object)
hhhh0000 (offset 6 from start of myData object)
l = low nybble, h = high nybble
So I end up here with 1 byte of data. I want to copy that byte to
another NSData object at offset 0, lets call that object myData2.
_______________________________________________
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: | |
| >NSData object (From: "Peter Karlsson" <email@hidden>) |