开发者

can I check if downloaded image is corrupt or not before saving?

开发者 https://www.devze.com 2023-02-25 07:41 出处:网络
can I check if downloaded image is corrupt or not before saving it into my document director开发者_如何学运维y?

can I check if downloaded image is corrupt or not before saving it into my document director开发者_如何学运维y? if yes then please tell me how? thank you


UIImage *im = [[UIImage alloc] initWithData:YourNSData];
UIImageView *imview;

// test to see if the image was successfully created
if (im){
   imview = [[UIImageView alloc] initWithImage:im];
}

Hope this helps


You could try to load the NSData object in a UIIImage with the initData. Then check if the return UIImage object is nil. This is not full proof methods, but should work.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号