Do you want to assign AnyObject? Int s array, beacuse objectForKey returns AnyObject? , so you should use it for the array as follows:
myArray = NSUserDefaults.standardUserDefaults().objectForKey("myArray") as [Int]
If there were no stored values ββbefore, it could return zero, so you can check it with:
if let temp = NSUserDefaults.standardUserDefaults().objectForKey("myArray") as? [Int] { myArray = temp }
source share