Trouble with binary data and byte buffers
Trouble with binary data and byte buffers
- Subject: Trouble with binary data and byte buffers
- From: Chase Meadors <email@hidden>
- Date: Tue, 14 Jul 2009 00:02:16 -0500
Hi, I'm having some confusion here over displaying raw binary data.
I have my NSMutableData object that I'm getting the bytes from. As I
understand it, there are different ways to get the bytes.
The -getBytes:range: method
NSRange r = NSMakeRange(x, y);
char buf[y];
[data getBytes:&buf length:r];
Or the -bytes or -mutableBytes methods
char buf = [data bytes];
What is the generally accepted method of doing this? I'm using the
first method, as the other one sometimes crashes.
Second, I'm testing the data with the following code:
for (int i = 0; i < aNumber; i ++) {
NSLog(@"X", buf[i]);
}
This is what's really bothering me because I'll get normal bytes, like
2E 00 AA, but sometimes, seemingly randomly, there are six leading
F's. Something like:
0E
00
FFFFFF8E
AA
FF
4E
FFFFFF0C
FFFFFF9A
9C
C0
Viewing the data in a hex editor reveals that the values on the end of
these F's are correct. For some reason, the data is just preceded by
extraneous F's...
Any help appreciated, thanks!
_______________________________________________
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