I have an NSData object that contains just <64>
which is supposed to represent the int 100
How can I convert this NSData to an int?
I can convert it to it's Chr
equivalent d
using
NSString *string = [[NSString alloc] initWithData:characteristic.value encoding:NSUTF8StringEncoding];
but I need the Dec
equivalent of 100
Thanks
<64>
means that the NSData
object contains a single byte with the value 0x64 = 100,
so the following should work;
const uint8_t *bytes = [data bytes]; // pointer to the bytes in data
int value = bytes[0]; // first byte