1

I want to put the Hex String to array

NSString *hex = @"1a2b3c";  //3 bytes
uint8_t array[3];
memcpy(array, [hex cStringUsingEncoding:NSUTF8StringEncoding] ,3);
NSData *data = [NSData dataWithBytes:&array length:3];
NSLog(@"%@" , data);

OUTPUT becomes ASCII: <316132>

If I want output to be <1A2B3C>, how should I do it ?

JosephT
  • 865
  • 1
  • 11
  • 20

0 Answers0