Ans :
NSUserDefault support format NSData for save. So convert image into NSData and then save.
Save image in NSUserDefault :
Get image from NSUserDefault :
NSUserDefault support format NSData for save. So convert image into NSData and then save.
Save image in NSUserDefault :
let defaults = NSUserDefaults.standardUserDefaults()
var imgData = UIImageJPEGRepresentation(image, 1)
defaults.setObject(imgData, forKey: "image")
let defaults = NSUserDefaults.standardUserDefaults()
if let imgData = defaults.objectForKey("image") as? NSData
{
if let image = UIImage(data: imgData)
{
self.imageView.image = image
}
}
No comments:
Post a Comment
Thanks