-
NSString 转 NSData
NSString * str = @"str"; NSData *data = [str dataUsingEncoding:NSUTF8StringEncoding];
-
NSData 转 NSString
NSString * str =[[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
-
data 转 char
NSData * data; char * haha = [data bytes];
-
char 转 data
byte * byteData = malloc(sizeof(byte)*16); NSData *content=[NSData dataWithBytes:byteData length:16];