ios - NSString stringWithFormat added "ffffff" -
i'm trying bytes nsdata , put in nsstring. while doing "ffffff" added simultaneously : char *array = (char *)[deviceinfo bytes]; return [nsstring stringwithformat:@"%02x:%02x:%02x:%02x:%02x:%02x", array[5],array[4],array[3],array[2],array[1],array[0]]; returns "53:ffffffcb:ffffffb8:51:09:fffffff0" the issue relates sign extension compiler promotes signed char unsigned int . numbers fffff negative. %x format expects unsigned int argument. declaring array correctly fix issue: const uint8_t *array = [deviceinfo bytes];