Type Method

dataWithBytesNoCopy:length:

Creates a data object that holds a given number of bytes from a given buffer.

Declaration

+ (instancetype)dataWithBytesNoCopy:(void *)bytes length:(NSUInteger)length;

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.

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

Creating Data

+ data

Creates an empty data object.

+ dataWithBytes:length:

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

+ dataWithBytesNoCopy:length:freeWhenDone:

Creates a data object that holds a given number of bytes from a given buffer.

+ dataWithData:

Creates a data object containing the contents of another data object.

- initWithBytes:length:

Initializes a data object filled with a given number of bytes copied from a given buffer.

- initWithBytesNoCopy:length:

Initializes a data object filled with a given number of bytes of data from a given buffer.

- initWithBytesNoCopy:length:deallocator:

Initializes a data object filled with a given number of bytes of data from a given buffer, with a custom deallocator block.

- initWithBytesNoCopy:length:freeWhenDone:

Initializes a newly allocated data object by adding the given number of bytes from the given buffer.

- initWithData:

Initializes a data object with the contents of another data object.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software