---
title: "decodeIntForKey:"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/nskeyedunarchiver/decodeintforkey:"
---

# decodeIntForKey:

Decodes an integer value associated with a given key.

## Declaration

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

## Parameters

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

## Return Value

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

## Discussion

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

### Related Documentation

- [encodeInt:forKey:](foundation/nskeyedarchiver/encodeint:forkey:.md)

### Decoding Data

- [containsValue(forKey:)](foundation/nskeyedunarchiver/containsvalue(forkey:).md)
- [decodeBool(forKey:)](foundation/nskeyedunarchiver/decodebool(forkey:).md)
- [decodeBytes(forKey:returnedLength:)](foundation/nskeyedunarchiver/decodebytes(forkey:returnedlength:).md)
- [decodeDouble(forKey:)](foundation/nskeyedunarchiver/decodedouble(forkey:).md)
- [decodeFloat(forKey:)](foundation/nskeyedunarchiver/decodefloat(forkey:).md)
- [decodeInt32(forKey:)](foundation/nskeyedunarchiver/decodeint32(forkey:).md)
- [decodeInt64(forKey:)](foundation/nskeyedunarchiver/decodeint64(forkey:).md)
- [decodeObject(forKey:)](foundation/nskeyedunarchiver/decodeobject(forkey:).md)
- [finishDecoding()](foundation/nskeyedunarchiver/finishdecoding().md)
- [decodingFailurePolicy](foundation/nskeyedunarchiver/decodingfailurepolicy.md)
