I am trying to save an array of a user-created class named "TopTenData". The code I used follows. Running the code indicates the file is created, but the file is NOT created. When I navigate to the path I do not find the desired file. Any help would be appreciated.
func writeArrayToPlist(array: [TopTenData]) {
if let arrayPath: String = createArrayPath() {
(array as NSArray).writeToFile(arrayPath, atomically: false)
print("Array written successfully")
print(arrayPath) // navigating this path shows no files
}
}
func createArrayPath () -> String? {
if let docsPath: String = NSSearchPathForDirectoriesInDomains(NSSearchPathDirectory.DocumentDirectory, NSSearchPathDomainMask.UserDomainMask, true).last {
return ((docsPath as NSString).stringByAppendingPathComponent("myTopTenData") as NSString).stringByAppendingPathExtension("plist")
}
return nil
}