-1

Hi I'm trying to storing array of images using swift but its not working

i use this for saving

     let defaults = NSUserDefaults.standardUserDefaults()
    defaults.setObject(photos, forKey: header)
    defaults.synchronize()

and this for loading

if let items = defaults.ArrayForKey(header) {
    self.photos = self.photos + items

 }

1 Answers1

0

If photos is an array of UIImage, this code will do nothing:

 defaults.setObject(photos...)

The reason is that UIImage is not a property list type. defaults is a property list. See Apple's docs:

https://developer.apple.com/library/ios/documentation/General/Conceptual/DevPedia-CocoaCore/PropertyList.html#//apple_ref/doc/uid/TP40008195-CH44-SW1

matt
  • 515,959
  • 87
  • 875
  • 1,141