Search code examples
iosobjective-cnsmutabledatauint8t

How do I create uint8_t with byte data?


I am trying to create uint8_t data with 2 bytes, and when I log the information after I have created it the saved information is incorrect(Or I am misunderstanding the LLDB logs).

uint8_t terminatingMessage[2];
terminatingMessage[0]=0x9E;
terminatingMessage[1]=0xEB;
NSMutableData *terminatorData = [NSMutableData dataWithBytes:(const void *)prepareMessage length:2];

When I break and log my "terminatorData" the value I get is B0F0. What I want and expect is to see 9EEB... What am I doing wrong ?


Solution

  • You're creating terminatorData from prepareMessage, but it looks like you meant to have terminatingMessage.