---
title: "decodeBytes(forKey:returnedLength:)"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/nscoder/decodebytes(forkey:returnedlength:)"
---

# decodeBytes(forKey:returnedLength:)

Decodes a buffer of data that was previously encoded with encodeBytes(_:length:forKey:) and associated with the string key.

## Declaration

```swift
func decodeBytes(forKey key: String, returnedLength lengthp: UnsafeMutablePointer<Int>?) -> UnsafePointer<UInt8>?
```

## Discussion

Discussion The buffer’s length is returned by reference in lengthp. The returned bytes are immutable. Subclasses must override this method if they perform keyed coding.

## See Also

### Related Documentation

- [encodeBytes(_:length:forKey:)](foundation/nscoder/encodebytes(_:length:forkey:).md)

### Decoding General Data

- [decodeArray(ofObjCType:count:at:)](foundation/nscoder/decodearray(ofobjctype:count:at:).md)
- [decodeBool(forKey:)](foundation/nscoder/decodebool(forkey:).md)
- [decodeBytes(withReturnedLength:)](foundation/nscoder/decodebytes(withreturnedlength:).md)
- [decodeData()](foundation/nscoder/decodedata().md)
- [decodeDouble(forKey:)](foundation/nscoder/decodedouble(forkey:).md)
- [decodeFloat(forKey:)](foundation/nscoder/decodefloat(forkey:).md)
- [decodeCInt(forKey:)](foundation/nscoder/decodecint(forkey:).md)
- [decodeInteger(forKey:)](foundation/nscoder/decodeinteger(forkey:).md)
- [decodeInt32(forKey:)](foundation/nscoder/decodeint32(forkey:).md)
- [decodeInt64(forKey:)](foundation/nscoder/decodeint64(forkey:).md)
- [decodeObject()](foundation/nscoder/decodeobject().md)
- [decodeObject(forKey:)](foundation/nscoder/decodeobject(forkey:).md)
- [decodePoint()](foundation/nscoder/decodepoint().md)
- [decodePoint(forKey:)](foundation/nscoder/decodepoint(forkey:).md)
- [decodePropertyList()](foundation/nscoder/decodepropertylist().md)
