Initializer

init(bytesNoCopy:length:)

Returns a data object initialized by adding to it a given number of bytes of data from a given buffer.

Declaration

init(bytesNoCopy bytes: UnsafeMutableRawPointer, length: Int)

Parameters

bytes

A buffer containing data for the new object. bytes must point to a memory block allocated with malloc.

length

The number of bytes to hold from bytes. This value must not exceed the length of bytes.

Return Value

A data object initialized by adding to it length bytes of data from the buffer bytes. The returned object might be different than the original receiver.

Discussion

The returned object takes ownership of the bytes pointer and frees it on deallocation. Therefore, bytes must point to a memory block allocated with malloc.

See Also

Related Symbols

init(bytesNoCopy: UnsafeMutableRawPointer, length: Int, freeWhenDone: Bool)

Initializes a newly allocated data object by adding to it length bytes of data from the buffer bytes.

dataWithBytes:length:

Creates and returns a data object containing a given number of bytes copied from a given buffer.

init(bytes: UnsafeRawPointer?, length: Int)

Returns a data object initialized by adding to it a given number of bytes of data copied from a given buffer.