如何将此字符串转换为 NSString?
How can I convert this string to NSString?
我得到以下 UUID 值:
0x70, 0x29, 0x78, 0x89, 0x64, 0xc4, 0x47, 0x67, 0xa1, 0x9a, 0x4a,
0x9f, 0xe4, 0x2b, 0xf9, 0x05
这是硬件开发者使用过的编码函数:
const UUID MY_SERVICE_UUID = createUuid({ 0x70, 0x29, 0x78, 0x89, 0x64, 0xc4, 0x47, 0x67, 0xa1, 0x9a, 0x4a, 0x9f, 0xe4, 0x2b, 0xf9, 0x05 });
我认为这是用十六进制表示的。这个对吗?
我需要将以上内容翻译成 NSString
才能使用。这样做有什么帮助吗?
这看起来像是 UUID 字节的十六进制表示。如果字节顺序正确,您可以像这样构造一个 NSString
:
const unsigned char uuidBytes[] = {0x70, 0x29, 0x78, 0x89, 0x64, 0xc4, 0x47, 0x67, 0xa1, 0x9a, 0x4a, 0x9f, 0xe4, 0x2b, 0xf9, 0x05};
NSUUID *uuid = [[NSUUID alloc] initWithUUIDBytes:uuidBytes];
NSString *uuidString = [uuid UUIDString];
我得到以下 UUID 值:
0x70, 0x29, 0x78, 0x89, 0x64, 0xc4, 0x47, 0x67, 0xa1, 0x9a, 0x4a,
0x9f, 0xe4, 0x2b, 0xf9, 0x05
这是硬件开发者使用过的编码函数:
const UUID MY_SERVICE_UUID = createUuid({ 0x70, 0x29, 0x78, 0x89, 0x64, 0xc4, 0x47, 0x67, 0xa1, 0x9a, 0x4a, 0x9f, 0xe4, 0x2b, 0xf9, 0x05 });
我认为这是用十六进制表示的。这个对吗?
我需要将以上内容翻译成 NSString
才能使用。这样做有什么帮助吗?
这看起来像是 UUID 字节的十六进制表示。如果字节顺序正确,您可以像这样构造一个 NSString
:
const unsigned char uuidBytes[] = {0x70, 0x29, 0x78, 0x89, 0x64, 0xc4, 0x47, 0x67, 0xa1, 0x9a, 0x4a, 0x9f, 0xe4, 0x2b, 0xf9, 0x05};
NSUUID *uuid = [[NSUUID alloc] initWithUUIDBytes:uuidBytes];
NSString *uuidString = [uuid UUIDString];