<!--
{
  "availability" : [
    "iOS: 2.0.0 -",
    "iPadOS: 2.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.0.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/NSCoder/decodeInt32(forKey:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSCoder(im)decodeInt32ForKey:"
  },
  "title" : "decodeInt32(forKey:)"
}
-->

# decodeInt32(forKey:)

Decodes and returns a 32-bit integer value that was previously encoded with [`encodeCInt(_:forKey:)`](/documentation/Foundation/NSCoder/encodeCInt(_:forKey:)), [`encode(_:forKey:)`](/documentation/Foundation/NSCoder/encode(_:forKey:)-2dprz), [`encode(_:forKey:)`](/documentation/Foundation/NSCoder/encode(_:forKey:)-5sk4z), or [`encode(_:forKey:)`](/documentation/Foundation/NSCoder/encode(_:forKey:)-dixg) and associated with the string `key`.

```
func decodeInt32(forKey key: String) -> Int32
```

## Discussion

If the encoded integer does not fit into a 32-bit integer, the method raises an `NSRangeException`. Subclasses must override this method if they perform keyed coding.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)