# iOS Apprentise 2. NSKeyedUnarchiver

**URL:** <https://forums.kodeco.com/t/ios-apprentise-2-nskeyedunarchiver/25450>\
**Category:** iOS Apprentice\
**Created:** [January 21, 2017, 5:30pm UTC](https://forums.kodeco.com/t/ios-apprentise-2-nskeyedunarchiver/25450 "2017-01-21T17:30:59Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![cheburashka](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/cheburashka/32/77219_2.png) [@cheburashka](https://forums.kodeco.com/u/cheburashka)\
**Post date:** [January 21, 2017, 5:30pm UTC](https://forums.kodeco.com/t/ios-apprentise-2-nskeyedunarchiver/25450/1 "2017-01-21T17:30:59Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![hollance](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/hollance/32/109009_2.png) [@hollance](https://forums.kodeco.com/u/hollance)\
**Post date:** [January 24, 2017, 9:17am UTC](https://forums.kodeco.com/t/ios-apprentise-2-nskeyedunarchiver/25450/2 "2017-01-24T09:17:00Z")

</div>

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