I am trying to save an array using NSUserDefaults() so that I can access the data even after closing the program. I Have always managed to use it successfully in the past saving Ints and Strings. However when I try to save an array it doesn't work. Here is an example:
var superarray = [AnyObject?]()
superarray.append("Test")
superarray.append(3)
superarray.append(NSDate()) //random examples
NSUserDefaults.standardUserDefaults().setObject(superarray, forKey: "AnyKey")
It gives the error: "Cannot convert value of type '[AnyObject?]' to expected argument type 'AnyObject?' "
Does this mean that .setObject() cannot take arrays? Is there another alternative?
Thanks in advance!