Skip to content

Instance Method

resetBytes(in:)

iOS 8.0+ iPadOS 8.0+ Mac Catalyst 8.0+ macOS 10.10+ tvOS 9.0+ watchOS 2.0+
Replaces the contents of the data buffer with zeros for the provided range.
mutating func resetBytes<R>(in range: R) where R : RangeExpression, Self.Index == R.Bound

Parameters

range

The range of bytes to replace with zeros.

Discussion

The following example sets the bytes to zero for the bytes identified by the provided range:

var dest: [UInt8] = [0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF]
dest.resetBytes(in: 1...3)
// dest = [0xFF, 0x00, 0x00, 0x00, 0xFF, 0xFF]

A default implementation is given in terms of replaceSubrange(_:with:).

Default Implementations

MutableDataProtocol Implementations