I've just started working with Swift, and I need to convert an Array to an NSArray for the purpose of writing to a plist file. Here's my code:
func saveDataToFile() {
var a:Array = [Any]()
for thing in self.objects {
var dictionary = [String:Any]()
dictionary["name"] = thing.name
dictionary["location"] = thing.location
a.append(dictionary)
}
let arr: NSArray = a
cocoaArray.writeToFile(filePath, atomically:true);
}
When I try to convert a into the NSArray arr, I get the error "Cannot convert value of type [Any] to specified type NSArray."