---
title: "getBytes(_:)"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/nsdata/getbytes(_:)"
---

# getBytes(_:)

Copies a data object’s contents into a given buffer.

## Declaration

```swift
func getBytes(_ buffer: UnsafeMutableRawPointer)
```

## Parameters

- `buffer`: A buffer into which to copy the receiver’s data. The buffer must be at least doc://com.apple.foundation/documentation/Foundation/NSData/length bytes.

## Discussion

Discussion You can see a sample using this method in Working With Binary Data.

## See Also

### Related Documentation

- [description](foundation/nsdata/description.md)

### Accessing Underlying Bytes

- [bytes](foundation/nsdata/bytes.md)
- [enumerateBytes(_:)](foundation/nsdata/enumeratebytes(_:).md)
- [getBytes(_:length:)](foundation/nsdata/getbytes(_:length:).md)
- [getBytes(_:range:)](foundation/nsdata/getbytes(_:range:).md)
