I need the bytes to change some bytes representing an unsigned integer of 16 bits. The following code works, but seems a little ridiculous:
CFSwapInt16(*(uint16_t*)[[myNSDataVariable] bytes]);
Here is what I deduced:
[[myNSDataVariable] bytes] returns a void pointer to an array of bytes.
(uint16_t*)outputs a void pointer to a pointer uint16_t.
The final external *plays the pointer uint16_t, providing access to the actual value uint16_t.
Is there a more elegant way to get value uint16_tfrom NSData?
Kevin source
share