var objects: AnyObject? = NSKeyedUnarchiver.unarchiveObjectWithData(data)
How to turn objects into NSMutableArray ? I archived NSMutableArray.
Just downcast the result to NSMutableArray:
if let objects = NSKeyedUnarchiver.unarchiveObjectWithData(data) as? NSMutableArray {
// ...
} else {
// failed
}
If the archived object is an (immutable) NSArray then you have to create a mutable
copy:
if let array = NSKeyedUnarchiver.unarchiveObjectWithData(data) as? NSArray {
let objects = NSMutableArray(array: array)
// ...
}
as? NSArray ?[AnyObject?] would be more "Swifty". I'm interested in what happens when you set an NSMutableArray to a let since you cannot change a let.. therefore making it a an NSArraylet, you can modify the referenced (mutable) array. It does not make it an NSArray.