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, or nsdictionary. if want store other type of object, should typically archive create instance of nsdata.

a function not of supported types, , far know cannot archive function either.


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -