---
title: "encode(_:forKey:)"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/nscoder/encode(_:forkey:)-dixg"
---

# encode(_:forKey:)

Encodes a 64-bit integer value and associates it with the string key.

## Declaration

```swift
func encode(_ value: Int64, forKey key: String)
```

## Discussion

Discussion Subclasses must override this method if they perform keyed coding.

## See Also

### Related Documentation

- [decodeCInt(forKey:)](foundation/nscoder/decodecint(forkey:).md)
- [decodeInt32(forKey:)](foundation/nscoder/decodeint32(forkey:).md)
- [decodeInt64(forKey:)](foundation/nscoder/decodeint64(forkey:).md)
- [decodeInteger(forKey:)](foundation/nscoder/decodeinteger(forkey:).md)

### Encoding General Data

- [encodeArray(ofObjCType:count:at:)](foundation/nscoder/encodearray(ofobjctype:count:at:).md)
- [encode(_:forKey:)](foundation/nscoder/encode(_:forkey:)-7o6mu.md)
- [encodeBycopyObject(_:)](foundation/nscoder/encodebycopyobject(_:).md)
- [encodeByrefObject(_:)](foundation/nscoder/encodebyrefobject(_:).md)
- [encodeBytes(_:length:)](foundation/nscoder/encodebytes(_:length:).md)
- [encodeBytes(_:length:forKey:)](foundation/nscoder/encodebytes(_:length:forkey:).md)
- [encodeConditionalObject(_:)](foundation/nscoder/encodeconditionalobject(_:).md)
- [encodeConditionalObject(_:forKey:)](foundation/nscoder/encodeconditionalobject(_:forkey:).md)
- [encode(_:)](foundation/nscoder/encode(_:)-1qd1e.md)
- [encode(_:forKey:)](foundation/nscoder/encode(_:forkey:)-9xiiu.md)
- [encode(_:forKey:)](foundation/nscoder/encode(_:forkey:)-84cez.md)
- [encodeCInt(_:forKey:)](foundation/nscoder/encodecint(_:forkey:).md)
- [encode(_:forKey:)](foundation/nscoder/encode(_:forkey:)-2dprz.md)
- [encode(_:forKey:)](foundation/nscoder/encode(_:forkey:)-5sk4z.md)
- [encode(_:)](foundation/nscoder/encode(_:)-9648d.md)
