You can create an array to store hexadecimal values, and then use it to create data:
unsigned char bytes[] = {0x0F}; NSData *data = [NSData dataWithBytes:bytes length:1];
This can be rewritten as:
NSData *data = [NSData dataWithBytes:(unsigned char[]){0x0F} length:1];
source share