iOS NSMutableDictionary中UIImage的存储和读取

思路:将UIImage转换成NSData,然后插入到NSMutableDictionary中,读取时,用NSData读出来,然后再转换成UIImage

-存储

UIImage *image = [self getPicture: id];
NSData *imageData = UIImagePNGRepresentation(image);
[tmpDic setObject:imageData forKey:@"imageData"];

-读取

NSData *imageData = [object objectForKey:@"imageData"];
if (imageData) {
    UIImage *image = [[UIImage alloc] initWithData:imageData];
    imageView.image = image;
}
else{
    //...
}

iOS NSMutableDictionary中UIImage的存储和读取,布布扣,bubuko.com

iOS NSMutableDictionary中UIImage的存储和读取

上一篇:Redis安装与配置( Windows10 )


下一篇:Web Application Stress 对网站进行压力测试