Persisting an array of images

2019-09-07 17:54发布

What's the best way to save and retrieve an array of images across app restarts? I'm implementing a caching feature for offline viewing of downloaded images and just want to make sure I'm using the right persisting methods.

Thanks!

1条回答
虎瘦雄心在
2楼-- · 2019-09-07 18:53

The quickest & probably best solution would be to persist your images to disk, no question about it.

You could do something like this to save them as JPEG.

NSData *data = UIImageJPEGRepresentation(image, 1.0f);
[data writeToFile:imagePath atomically:YES];
查看更多
登录 后发表回答