ios - Save a function to NSUserDefaults in Swift -
so, wondering if possible save function user defaults using swift. string, example, this:
var inputdata = "hi" nsuserdefaults.standarduserdefaults.setvalueforkey(inputdata, forkey: "data") then save variable, say:
var gotdata = nsuserdefaults.standarduserdefaults.valueforkey("data")! now, question is, if possible save function user defaults. example:
var inputdata = func helloworld(){println("hello world!")} is possible call function saved user defaults doing similar .valueforkey ?
any valued! lot in advance!
you cannot save function nsuserdefaults. nsuserdefaults class reference:
a 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.
a function not of supported types, , far know cannot archive function either.
Comments
Post a Comment