//Byte就是unsigned char
//第一种方式 Byte ---- > NSData
Byte byte[] = {0x01,0x0d};
NSData * data = [[NSData alloc] initWithBytes:byte length:2];
NSLog(@"%@",data); ///<010d>
//第二种方式 unsigned char ---- > NSData
unsigned char * charStr = (unsigned char*)[@"ni" UTF8String];
NSData * data1 = [NSData dataWithBytes:(const char *)charStr length:strlen((const char *)charStr)];
NSLog(@"%@",data1); ///<6e69>
macOS - unsigned char ---- > NSData
最新推荐文章于 2024-07-04 20:12:35 发布