NSKeyedArchiver does not work in Swift 3 ( XCode 8)
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have migrated my project to Swift 3 and NSKeyedArchiver does not work. I actually have a runtime error when trying to decode object like this: let startDayTime = aDecoder.decodeObject(forKey: Key.startDayTime) as! Int It worked perfectly in Swift 2.2 in Xcode 7.3. Has anybody else faced such troubles? P.S. I have this error on both Simulator and Device. UPDATE: I solved this problem by using decodeInteger(forKey key: String) instead of decodeObject(forKey key: String) . By some reason AnyObject does not cast to Integer in Swift 3 though it