Instance MethodFoundationEssentials
copyBytes(to:from:)
iOS 8.0+
iPadOS 8.0+
Mac Catalyst 8.0+
macOS 10.10+
tvOS 9.0+
watchOS 2.0+
Copies a range of the bytes from the type into a typed memory buffer.
func copyBytes<DestinationType, R>(to ptr: UnsafeMutableBufferPointer<DestinationType>, from range: R) where R : RangeExpression, Self.Index == R.Bound
Parameters
ptrA typed pointer to the buffer you want to copy the bytes into.
rangeThe range of bytes to copy.
Discussion
This specialization is available when the conforming type also conforms to ContiguousBytes, and copies bytes directly using memcpy for better performance.