Skip to content

Instance MethodFoundationEssentials

enumerateBytes(_:)

iOS 8.0+ iPadOS 8.0+ Mac Catalyst 8.0+ macOS 10.10+ tvOS 9.0+ watchOS 2.0+ SwiftDeprecated

Deprecated

This symbol is deprecated.

Enumerates the contents of the data’s buffer.
func enumerateBytes(_ block: (UnsafeBufferPointer<UInt8>, Data.Index, inout Bool) -> Void)

Parameters

block

The closure to invoke for each region of data. You may stop the enumeration by setting the stop parameter to true.

Discussion

In some cases, (for example, a Data backed by a dispatch_data_t, the bytes may be stored discontinuously. In those cases, this function invokes the closure for each contiguous region of bytes.