Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
save and load a Swift Dictionary to NSUserDefaults
//save dict to userDefaults
var data = NSKeyedArchiver.archivedDataWithRootObject(places)
NSUserDefaults.standardUserDefaults().setObject(data, forKey: "places")
var data = NSUserDefaults.standardUserDefaults().objectForKey("places") as! NSData
places = NSKeyedUnarchiver.unarchiveObjectWithData(data) as! [Dictionary<String,String>]
Copy link

AnupSukumaran commented Dec 13, 2017

got error like this -
NSForwarding: warning: object 0x60000010add0 of class 'Laundrybe.PlaceOrderModel' does not implement methodSignatureForSelector: -- trouble ahead
Unrecognized selector -[Laundrybe.PlaceOrderModel replacementObjectForKeyedArchiver:]
2017-12-13 15:17:55.185450+0530 Laundrybe[14255:585055] Unrecognized selector -[Laundrybe.PlaceOrderModel replacementObjectForKeyedArchiver:]


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment