How to save image

前端 未结 3 975
挽巷
挽巷 2021-01-27 09:27

I want to save image with userdefaults and use it in another view with this code but it shows an error .

UserDefaults.standard.set(img , forKey : \"simg\")
         


        
3条回答
  •  生来不讨喜
    2021-01-27 09:45

    As others have said, don't save images to user defaults. It's only intended for small bits of data.

    If all you want to do is to pass an image in another view controller, and you don't care about making the image persist if the user quits and re-launches the app, just pass the image in prepareForSegue.

提交回复
热议问题