iOS Apprentise 2. NSKeyedUnarchiver

Instead of

let path = dataFilePath()
if let data = try? Data(contentsOf: path) {
let unarchiver = NSKeyedUnarchiver(forReadingWith: data)
items = unarchiver.decodeObject(forKey: “ChecklistItems”)
unarchiver.finishDecoding()
}

why not just to use NSKeyedUnarchiver.unarchiveObjectWithFile(some_path) as? [ChecklistItem] in loading and NSKeyedArchiver.archiveRootObject(items, toFile: some_path) in saving accordingly?

There’s often more than one way to do something. :smile: