Trying to archive an array of Codable
elements.
do {
let data = try PropertyListEncoder().encode(elements)
let success = NSKeyedArchiver.archiveRootObject(data, toFile:self.archiveURL.path)
print(success ? "Successful save" : "Save Failed")
} catch {
print("Save Failed")
}
For some reason path (archiveURL
) is constantly wrong:
let archiveURL = FileManager().urls(for: .documentDirectory, in: .userDomainMask).first!
is returning always URL like this:
file:///Users/userName/Library/Developer/CoreSimulator/Devices/deviceID/data/Documents
but searching through folders I see no /Documents folder. Has something changed recently? It used to work few weeks back (pretty sure). Super annoying and I can't find any workaround/fix for that.