I\'m trying to save images retrieved from Parse.com like this:
let userImageFile = object[\"Image\"] as PFFile
userImageF
It seems like you do not call defaults.synchronize()
so it's not written to the defaults file.
Swift 3
Hey, try this beautiful code here:
Convert your UIImage to Data
.
PNG:
yourDataImagePNG = UIImagePNGRepresentation(yourUIImageHere)
JPEG :
yourDataImageJPG = UIImage(data: yourUIImageHere,scale:1.0)
UserDefaults().set(yourDataImagePNG, forKey: "image")
UserDefaults.standard.object(forKey: "image") as! Data
I hope to help!