ios - Saving AnyObject to NSUserdefaults -


this question has answer here:

i'm working on swift application interacts shopify api through mobile buy sdk. i'm having issues saving cart device. else works fine, when use following code save cart device:

  func savecart() {     nsuserdefaults.standarduserdefaults().setobject(cart, forkey: "cart")     println("cart saved")   } 

i receive following error:

terminating app due uncaught exception 'nsinvalidargumentexception', reason: 'attempt insert non-property list object <buycart: 0x7fb5e30512f0> key cart' 

from nsuserdefaults class reference:

the nsuserdefaults class provides convenience methods accessing common types such floats, doubles, integers, booleans, , urls. default object must property list, is, instance of (or collections combination of instances of): nsdata, nsstring, nsnumber, nsdate, nsarray, or nsdictionary. if want store other type of object, should typically archive create instance of nsdata. more details, see preferences , settings programming guide.

hope helps!


Comments

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

Delphi 7 and decode UTF-8 base64 -

html - Is there any way to exclude a single element from the style? (Bootstrap) -