Save UIImage array in NSUserDefaults

后端 未结 4 1077
栀梦
栀梦 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 00:51

    Simple approach, convert UIImages to NSData. Then add image data’s into an NSArray. Then save the NSArray into UserDefault. When retrieving the NSArray from UserDefault,use ImageWithData method to render UIImage from the NSArray’s each elements. This is the easiest process if you really one to use UserDefaults for your purpose. Try this yourself.

提交回复
热议问题