1. UIView -> UIImage
-(UIImage *)getImageFromView:(UIView *)view{
UIGraphicsBeginImageContext(view.bounds.size);
[view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return image;
}
2. UIImage -> NSData
NSData *data = UIImagePNGRepresentation(image);
3. NSDictionary <-> NSData
NSDictionary *dic = @{@"name":@"macRong",@"webHome":@"eqi.cc"};
NSData *data = [NSJSONSerialization dataWithJSONObject:dic options:NSJSONWritingPrettyPrinted error:nil];
NSDictionary *dictionary = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:nil];