how to store and fetch array of image from nsuserdefaults in swift?



i have the following code


this code is used to set the array in nsuserdefault



let data=NSKeyedArchiver.archivedDataWithRootObject(allCheckBoxList!)
NSUserDefaults.standardUserDefaults().setObject(data, forKey: "Check_Box_Status")


this code is used to access the array but giving different values in array



let data=NSUserDefaults.standardUserDefaults().objectForKey("Check_Box_Status") as? NSData
allCheckBoxList=NSKeyedUnarchiver.unarchiveObjectWithData(data!) as? [UIImage]

No comments:

Post a Comment