Returns a new instance of the given type, read from the buffer pointer’s raw memory at the specified byte offset.
- Xcode 8.0+
- Swift Standard Library
The offset, in bytes, into the buffer pointer’s memory at which to begin reading data for the new instance. The buffer pointer plus
offsetmust be properly aligned for accessing an instance of type
T. The default is zero.
The type to use for the newly constructed instance. The memory must be initialized to a value of a type that is layout compatible with
A new instance of type
T, copied from the buffer pointer’s memory.
You can use this method to create new values from the buffer pointer’s underlying bytes. The following example creates two new
Int32 instances from the memory referenced by the buffer pointer
some. The bytes for
a are copied from the first four bytes of
some, and the bytes for
b are copied from the next four bytes.
The memory to read for the new instance must not extend beyond the buffer pointer’s memory region—that is,
offset + Memory must be less than or equal to the buffer pointer’s