//UIIamge 转 NSData
UIIamge *image = [UIImage imageNamed:@"imageName.png"];
NSData *imageData = UIImagePNGRepresentation(image]);
//NSData 转 UIIamge
NSData *data;
UIImage *image = [UIImage imageWithData:data];
//JSON字符串 转 NSDictionary
/*
NSJSONReadingOptions:
NSJSONReadingMutableLeaves
NSJSONReadingMutableContainers
NSJSONReadingAllowFragments
*/
NSString *string = @"{\"userId\":1,\"userName\":\"username\",\"nickName\":\"nickname\"}";
NSData *data = [string dataUsingEncoding:NSUTF8StringEncoding];
NSDictionary *dictionary = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableLeaves error:nil];
网友评论