Calls the given closure with a pointer to the underlying bytes of the array’s contiguous storage.
- Xcode 8.0+
- Swift Standard Library
A closure with an
Unsafeparameter that points to the contiguous storage for the array. If no such storage exists, it is created. If
Raw Buffer Pointer
bodyhas a return value, that value is also used as the return value for the
withmethod. The argument is valid only for the duration of the closure’s execution.
The return value, if any, of the
body closure parameter.
Element type must be a trivial type, which can be copied with just a bit-for-bit copy without any indirection or reference-counting operations. Generally, native Swift types that do not contain strong or weak references are trivial, as are imported C structs and enums.
The following example copies the bytes of the
numbers array into a buffer of