withUnsafeBytes(_:)
Calls the given closure with a pointer to the underlying bytes of the array’s contiguous storage.
- iOS
- 13+
- macOS
- 10.15+
- tvOS
- 13+
- watchOS
- 6+
func withUnsafeBytes<R>(_ body: (UnsafeRawBufferPointer) throws -> R) rethrows -> R
Parameters
- body
A closure with an
UnsafeRawBufferPointer
parameter that points to the contiguous storage for the array. The system creates the storage if it doesn’t exist. If body 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.