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.
bytesmust point to a memory block allocated withmalloc. - length:
The number of bytes to hold from
bytes. This value must not exceed the length ofbytes.
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.