Contents

Data

A byte buffer in memory.

Declaration

@frozen struct Data

Mentioned in

Overview

The Data value type allows simple byte buffers to take on the behavior of Foundation objects. You can create empty or pre-populated buffers from a variety of sources and later add or remove bytes. You can filter and sort the content, or compare against other buffers. You can manipulate subranges of bytes and iterate over some or all of them.

Data bridges to the NSData class and its mutable subclass, NSMutableData. You can use these interchangeably in code that interacts with Objective-C APIs.

Topics

Creating Empty Data

Creating Populated Data

Creating Data from Raw Memory

Reading and Writing Data

Base-64 Encoding

Accessing Bytes

Accessing Underlying Memory

Adding Bytes

Replacing a Range of Bytes

Finding Bytes

Excluding Bytes

Iterating Over Bytes

Splitting the Buffer

Comparing Data

Manipulating Indexes

Describing Data

Using Reference Types

Initializers

Instance Properties

Instance Methods

Subscripts

Default Implementations

See Also

Binary Data