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(@"%02X", 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 (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to