---
title: DispatchData
framework: dispatch
role: symbol
role_heading: Structure
path: dispatch/dispatchdata
---

# DispatchData

An object that manages a memory-based data buffer and exposes it as a contiguous block of memory.

## Declaration

```swift
struct DispatchData
```

## Overview

Overview The memory buffer managed by this object may be a single contiguous block of memory, or it may consist of multiple discontiguous blocks. For the discontiguous case, the dispatch data object makes it appear as if the memory is contiguous.

## Topics

### Creating a Dispatch Data Structure

- [init(bytes:)](dispatch/dispatchdata/init(bytes:)-9lrd.md)
- [init(bytesNoCopy:deallocator:)](dispatch/dispatchdata/init(bytesnocopy:deallocator:)-vfoe.md)
- [withUnsafeBytes(body:)](dispatch/dispatchdata/withunsafebytes(body:).md)
- [DispatchData.Deallocator](dispatch/dispatchdata/deallocator.md)
- [empty](dispatch/dispatchdata/empty.md)

### Appending Data to the Buffer

- [append(_:)](dispatch/dispatchdata/append(_:)-3bvdr.md)
- [append(_:)](dispatch/dispatchdata/append(_:)-9sgkq.md)
- [append(_:)](dispatch/dispatchdata/append(_:)-1m94x.md)

### Copying Bytes

- [copyBytes(to:count:)](dispatch/dispatchdata/copybytes(to:count:)-3j0qx.md)
- [copyBytes(to:from:)](dispatch/dispatchdata/copybytes(to:from:)-7zz4y.md)
- [copyBytes(to:from:)](dispatch/dispatchdata/copybytes(to:from:)-60yai.md)

### Accessing Buffer Data

- [subscript(_:)](dispatch/dispatchdata/subscript(_:).md)
- [region(location:)](dispatch/dispatchdata/region(location:).md)
- [DispatchData.Region](dispatch/dispatchdata/region.md)

### Iterating Over the Buffer Contents

- [makeIterator()](dispatch/dispatchdata/makeiterator().md)
- [enumerateBytes(_:)](dispatch/dispatchdata/enumeratebytes(_:).md)

### Retrieving Buffer Subsequences

- [subdata(in:)](dispatch/dispatchdata/subdata(in:).md)

### Combining Sequence Elements

- [append(_:)](dispatch/dispatchdata/append(_:)-3bvdr.md)
- [append(_:)](dispatch/dispatchdata/append(_:)-9sgkq.md)
- [append(_:)](dispatch/dispatchdata/append(_:)-1m94x.md)
- [append(_:count:)](dispatch/dispatchdata/append(_:count:).md)
- [copyBytes(to:count:)](dispatch/dispatchdata/copybytes(to:count:)-4ffyj.md)
- [copyBytes(to:count:)](dispatch/dispatchdata/copybytes(to:count:)-3j0qx.md)
- [copyBytes(to:from:)](dispatch/dispatchdata/copybytes(to:from:)-7zz4y.md)
- [copyBytes(to:from:)](dispatch/dispatchdata/copybytes(to:from:)-6ztcb.md)
- [copyBytes(to:from:)](dispatch/dispatchdata/copybytes(to:from:)-60yai.md)
- [enumerateBytes(_:)](dispatch/dispatchdata/enumeratebytes(_:).md)
- [makeIterator()](dispatch/dispatchdata/makeiterator().md)
- [region(location:)](dispatch/dispatchdata/region(location:).md)
- [subdata(in:)](dispatch/dispatchdata/subdata(in:).md)
- [withUnsafeBytes(body:)](dispatch/dispatchdata/withunsafebytes(body:).md)

### Deprecated

- [init(bytes:)](dispatch/dispatchdata/init(bytes:)-mkbp.md)
- [init(bytesNoCopy:deallocator:)](dispatch/dispatchdata/init(bytesnocopy:deallocator:)-7h08w.md)
- [append(_:count:)](dispatch/dispatchdata/append(_:count:).md)
- [copyBytes(to:count:)](dispatch/dispatchdata/copybytes(to:count:)-4ffyj.md)
- [copyBytes(to:from:)](dispatch/dispatchdata/copybytes(to:from:)-6ztcb.md)

### Instance Methods

- [enumerateBytes(block:)](dispatch/dispatchdata/enumeratebytes(block:).md)

## Relationships

### Conforms To

- [BidirectionalCollection](swift/bidirectionalcollection.md)
- [Collection](swift/collection.md)
- [Copyable](swift/copyable.md)
- [DataProtocol](foundation/dataprotocol.md)
- [Escapable](swift/escapable.md)
- [RandomAccessCollection](swift/randomaccesscollection.md)
- [Sendable](swift/sendable.md)
- [SendableMetatype](swift/sendablemetatype.md)
- [Sequence](swift/sequence.md)

## See Also

### System Event Monitoring

- [DispatchSource](dispatch/dispatchsource.md)
- [Dispatch Source](dispatch/dispatch-source.md)
- [DispatchIO](dispatch/dispatchio.md)
- [DispatchDataIterator](dispatch/dispatchdataiterator.md)
- [Dispatch I/O](dispatch/dispatch-i-o.md)
- [Dispatch Data](dispatch/dispatch-data.md)
- [DispatchSourceProtocol](dispatch/dispatchsourceprotocol.md)
