Re: NSData dataWithBytes:Length: all 00
Re: NSData dataWithBytes:Length: all 00
- Subject: Re: NSData dataWithBytes:Length: all 00
- From: James Walker <email@hidden>
- Date: Tue, 21 Jul 2009 13:49:10 -0700
Chase Meadors wrote:
I have the following code, which is a category on NSData. It is always
called on especially designated NSData objects with four bytes.
- (NSData *)resolve {
unsigned char *buf = [self bytes];
const unsigned char *newBytes[4] = { (buf[3] - 0x08), buf[2],
buf[1], buf[0] };
You've declared an array of pointers to bytes, not an array of bytes.
Take out that asterisk.
for (int i = 0; i < 4; i ++) {
NSLog(@"X", newBytes[i]);
}
NSData *ret = [NSData dataWithBytes:newBytes length:4];
return ret;
}
The for statement logging the individual bytes is exactly as expected.
However, the new data object ret is <00000000>. I couldn't really find
an answer on google, probably because it's a simple answer I'm missing,
so I asked here. Thanks for any help.
_______________________________________________
--
James W. Walker, Innoventive Software LLC
<http://www.frameforge3d.com/>
_______________________________________________
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