withUnsafeBytes(_:)
Calls the given closure with a pointer to a copy of the underlying bytes of the array’s storage.
func withUnsafeBytes<R>(_ body: (UnsafeBufferPointer<Element>) throws -> R) rethrows -> R
Parameters
- body
A closure with an
UnsafeBufferPointer
parameter that points to the contiguous storage for the array. Ifbody
has a return value, that value is also used as the return value for thewithUnsafeBytes(_:)
method. The argument is valid only for the duration of the closure’s execution.
Returns
The return value, if any, of the body
closure parameter.