Instance Method

enumerateBytes(_:)

Enumerates the contents of the data's buffer.

Declaration

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 discontiguously. In those cases, this function invokes the closure for each contiguous region of bytes.

See Also

Iterating Over Bytes

func forEach((UInt8) -> Void)

Calls the given closure on each element in the sequence in the same order as a for-in loop.

func enumerated() -> EnumeratedSequence<Data>

Returns a sequence of pairs (n, x), where n represents a consecutive integer starting at zero and x represents an element of the sequence.

func makeIterator() -> Data.Iterator

Returns an iterator over the contents of the data.

struct Data.Iterator

An iterator that operates over the contents of data.