[英]How to convert UUID into 16 bytes UInt8 array in MacOS Objective C / C++
I can get UUID string using below code ..我可以使用以下代码获取 UUID 字符串..
CFUUIDRef theUUID = CFUUIDCreate(NULL);
CFStringRef string = CFUUIDCreateString(NULL, theUUID);
Or I can get bytes using below code或者我可以使用以下代码获取字节
CFUUIDRef theUUID = CFUUIDCreate(NULL);
CFUUIDBytes bytes = CFUUIDGetUUIDBytes(theUUID);
But I would like to make an array of UInt8 and as the UUID is 16 bytes, so the output array should be in 16 bytes.但我想制作一个 UInt8 数组,因为 UUID 是 16 字节,所以输出数组应该是 16 字节。
By examining the CFUUIDBytes typedef you can see how to access each byte:通过检查CFUUIDBytes typedef,您可以了解如何访问每个字节:
CFUUIDRef theUUID = CFUUIDCreate(NULL);
CFUUIDBytes bytes = CFUUIDGetUUIDBytes(theUUID);
UInt8 rawData[16];
rawData[0] = bytes.byte0;
rawData[1] = bytes.byte1;
...
rawData[15] = bytes.byte15;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.