Re: NSData to long
Re: NSData to long
- Subject: Re: NSData to long
- From: Bill Haller <email@hidden>
- Date: Tue, 8 Apr 2003 08:48:15 -0400
Okay, now I understand the question.
// set up a test NSData that is 4 bytes long
NSData * theData = [NSData dataWithBytes:@"\0\0\0\0" length:4];
*(long unsigned *) [theData bytes] = 36;
NSLog(@"theData %@",theData); // yields : theData <00000024 >
// Cast the bytes to an unsigned long pointer, dereference, use format
stuff
NSString * theString =
[NSString stringWithFormat:@"%u", *(long unsigned *)[theData
bytes]];
NSLog(theString); // yields 36
- Bill Haller
_______________________________________________
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.