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
nsuserdefaultsclass 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, ornsdictionary. if want store other type of object, should typically archive create instance ofnsdata. more details, see preferences , settings programming guide.
hope helps!
Comments
Post a Comment