将UIImage数组保存在NSUserDefaults中 [英] Save UIImage array in NSUserDefaults
本文介绍了将UIImage数组保存在NSUserDefaults中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想将 UIImage
数组放入 UserDefaults
中,然后进行检索。之后,在图像视图中设置检索到的图像。我该怎么做?
I want to put a UIImage
array into UserDefaults
and then retrieve it. After that set the retrieved images in an image view. How can I do that?
推荐答案
您可以轻松地将图像保存在documentDirectory中,如下所示:
You can easily save your image in documentDirectory as below:
let documentDirectory = FileManager.default.urls(for:.documentDirectory,in:.userDomainMask).first
let fileURL = documentDirectory?.appendingPathComponent(yourImageName)
然后,您可以将图像提供给UserDefaults
and then, you can give your image to UserDefaults
这篇关于将UIImage数组保存在NSUserDefaults中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文