---
title: "dataWithBytesNoCopy:length:"
framework: foundation
role: symbol
role_heading: Type Method
path: "foundation/nsdata/datawithbytesnocopy:length:"
---

# dataWithBytesNoCopy:length:

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

## Declaration

```occ
+ (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

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](foundation/nsdata/data.md)
- [dataWithBytes:length:](foundation/nsdata/datawithbytes:length:.md)
- [dataWithBytesNoCopy:length:freeWhenDone:](foundation/nsdata/datawithbytesnocopy:length:freewhendone:.md)
- [dataWithData:](foundation/nsdata/datawithdata:.md)
- [init(bytes:length:)](foundation/nsdata/init(bytes:length:).md)
- [init(bytesNoCopy:length:)](foundation/nsdata/init(bytesnocopy:length:).md)
- [init(bytesNoCopy:length:deallocator:)](foundation/nsdata/init(bytesnocopy:length:deallocator:).md)
- [init(bytesNoCopy:length:freeWhenDone:)](foundation/nsdata/init(bytesnocopy:length:freewhendone:).md)
- [init(data:)](foundation/nsdata/init(data:).md)
