Skip to content

Structure

Data

iOS 8.0+ iPadOS 8.0+ Mac Catalyst 8.0+ macOS 10.10+ tvOS 9.0+ watchOS 2.0+
A byte buffer in memory.
@frozen struct Data

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

Structures

Initializers

Instance Properties

Instance Methods

Subscripts

  • subscript(_:)
    Accesses the bytes at the specified range of indexes.

Type Aliases

Enumerations

  • enum Deallocator
    A deallocator you use to customize how the backing store is deallocated for data created with the no-copy initializer.

Default Implementations

Relationships

Conforms To

  • ContiguousBytes
  • DataProtocol
  • MultipartKit.MultipartPartConvertible
  • MutableDataProtocol
  • Swift.BidirectionalCollection
  • Swift.Collection
  • Swift.Copyable
  • Swift.CustomDebugStringConvertible
  • Swift.CustomReflectable
  • Swift.CustomStringConvertible
  • Swift.Decodable
  • Swift.Encodable
  • Swift.Equatable
  • Swift.Escapable
  • Swift.Hashable
  • Swift.MutableCollection
  • Swift.RandomAccessCollection
  • Swift.RangeReplaceableCollection
  • Swift.Sendable
  • Swift.SendableMetatype
  • Swift.Sequence