『导言』
iOS 开发中NSData
转NSString
?如下所示:
-
方法:
dataUsingEncoding:
-
案例如下:
- 代码:
NSString *str = @"username=zwj&pwd=123&type=JSON";
NSData *data = [str dataUsingEncoding:NSUTF8StringEncoding];
NSLog(@"\nstr = %@\n-------\n data = %@\n",str,data);
- 打印结果:
str = username=zwj&pwd=123&type=JSON
data = <75736572 6e616d65 3d7a776a 26707764 3d313233 26747970 653d4a53 4f4e>