中文转码
str = [str stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
图片编码
NSData *data;
NSData -->UIImage
UIImage *image = [UIImage imageWithData:data];
UIImage-->NSData
NSData *data1 = UIImagePNGRepresentation(image);
NSData *data2 = UIImageJPEGRepresentation(image, 1.0);
NSData -->NSString
str = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
NSString --> NSData
NSData *strData = [str dataUsingEncoding:NSUTF8StringEncoding];