<!--
{
  "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/NSKeyedUnarchiver/decodeIntForKey:",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSKeyedUnarchiver(im)decodeIntForKey:"
  },
  "title" : "decodeIntForKey:"
}
-->

# decodeIntForKey:

Decodes an integer value associated with a given key.

```
- (int) decodeIntForKey:(NSString *) key;
```

## Parameters

`key`

A key in the archive within the current decoding scope. `key` must not be `nil`.

## Return Value

The integer value associated with the key `key`. Returns `0` if `key` does not exist.

## Discussion

If the archived value was encoded with a different size but is still an integer, the type is coerced. If the archived value is too large to fit into the default size for an integer, the method raises an `NSRangeException`.

## See Also

[`-  encodeInt:forKey:`](/documentation/Foundation/NSKeyedArchiver/encodeInt:forKey:)

Encodes a given `int` value and associates it with a key.



---

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)