【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>>
NSString 转 byte字节
NSData *strDataBytes = [@"$$" dataUsingEncoding:NSUTF8StringEncoding];
转换结果为{0x24, 0x24};
int 转 byte
NSMutableData *myData = [[NSMutableData alloc] init];
int num = 1024;
[myData appendBytes:&num length:sizeof(num)];
Byte数组 转 NSData
Byte *bytes = {***};
NSData *strData = [NSData dataWithBytes:bytes length:strlen];
NSData 转 NSString
NSData *strData = ***;
NSString* string = [[NSString alloc] initWithData:strData encoding:NSUTF8StringEncoding];
来源:oschina
链接:https://my.oschina.net/u/1402271/blog/277844