---
title: "decodeBytes(withReturnedLength:)"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/nscoder/decodebytes(withreturnedlength:)"
---

# decodeBytes(withReturnedLength:)

Decodes a buffer of data whose types are unspecified.

## Declaration

```swift
func decodeBytes(withReturnedLength lengthp: UnsafeMutablePointer<Int>) -> UnsafeMutableRawPointer?
```

## Discussion

Discussion NSCoder‘s implementation invokes decodeValue(ofObjCType:at:) to decode the data as a series of bytes, which this method then places into a buffer and returns. The buffer’s length is returned by reference in numBytes. If you need the bytes beyond the scope of the current @autoreleasepool block, you must copy them. This method matches an encodeBytes(_:length:) message used during encoding.

## See Also

### Related Documentation

- [encodeArray(ofObjCType:count:at:)](foundation/nscoder/encodearray(ofobjctype:count:at:).md)

### Decoding General Data

- [decodeArray(ofObjCType:count:at:)](foundation/nscoder/decodearray(ofobjctype:count:at:).md)
- [decodeBool(forKey:)](foundation/nscoder/decodebool(forkey:).md)
- [decodeBytes(forKey:returnedLength:)](foundation/nscoder/decodebytes(forkey:returnedlength:).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)
