Why doesn't my Swift 3.0 decoder decodeInteger work for integers? <p>So we've been using Groups for saving and retrieving some data across an extension and the main app and everything worked fine for Swift 2.3 but then we updated to Swift 3.0 and got some issues.</p> <p>The current implementation that gives us issues is like following:</p> <pre><code>open class SomeClass: NSObject, NSCoding { open var someVar: Int! open func encode(with aCoder: NSCoder) { aCoder.encode(self.someVar, forKey:"someVar") } public required convenience init?(coder decoder: NSCoder) { // this is where it breaks self.someVar = decoder.decodeInteger(forKey: "someVar") } } </code></pre> <p>The following error is thrown:</p> <pre><code>*** Terminating app due to uncaught exception 'NSInvalidUnarchiveOperationException', reason: '*** -[NSKeyedUnarchiver decodeInt32ForKey:]: value for key (someVar) is not an integer number' </code></pre> <p>The funny thing is the old implementation for Swift 2.3 works without any issues: <code>self.someVar = decoder.decodeObject(forKey: "someVar") as! Int</code> (I've understood from other posts that this would not work...)</p> <p>So what could I be doing wrong? It should be said that the original value is retrieved from a float and cast to an int.</p>