Save UIImage array in NSUserDefaults

后端 未结 4 1128
栀梦
栀梦 2021-01-26 00:30

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?

4条回答
  •  耶瑟儿~
    2021-01-26 01:04

    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)

    and then, you can give your image to UserDefaults

提交回复
热议问题