---
title: initWithBytesNoCopy
framework: kernel
role: pseudoSymbol
path: kernel/osdata/1808127-initwithbytesnocopy
---

# initWithBytesNoCopy

Initializes an instance of OSData to share the provided data buffer.

## Declaration

```occ
virtual bool initWithBytesNoCopy( 
 void *bytes, 
 unsigned intnumBytes); 
```

## Parameters

- `bytes`: The buffer of data to represent.
- `numBytes`: The length of bytes.

## Return Value

Return Value true on success, false on failure.

## Overview

Overview Not for general use. Use the static instance creation method withBytesNoCopy instead. An OSData object initialized with this function does not claim ownership of the data buffer, but merely shares it with the caller. An OSData object created with shared external data cannot append bytes, but you can get the byte pointer and modify bytes within the shared buffer.

## See Also

### Miscellaneous

- [appendByte](kernel/osdata/1808052-appendbyte.md)
- [appendBytes(const OSData *)](kernel/osdata/1808058-appendbytes.md)
- [appendBytes(const void *, unsigned int)](kernel/osdata/1808067-appendbytes.md)
- [ensureCapacity](kernel/osdata/1808072-ensurecapacity.md)
- [free](kernel/osdata/1808080-free.md)
- [getBytesNoCopy()](kernel/osdata/1808085-getbytesnocopy.md)
- [getBytesNoCopy(unsigned int, unsigned int)](kernel/osdata/1808094-getbytesnocopy.md)
- [getCapacity](kernel/osdata/1808100-getcapacity.md)
- [getCapacityIncrement](kernel/osdata/1808106-getcapacityincrement.md)
- [getLength](kernel/osdata/1808111-getlength.md)
- [initWithBytes](kernel/osdata/1808118-initwithbytes.md)
- [initWithCapacity](kernel/osdata/1808134-initwithcapacity.md)
- [initWithData(const OSData *)](kernel/osdata/1808141-initwithdata.md)
- [initWithData(const OSData *, unsigned int, unsigned int)](kernel/osdata/1808150-initwithdata.md)
- [isEqualTo(const OSData *)](kernel/osdata/1808160-isequalto.md)
- [isEqualTo(const OSMetaClassBase *)](kernel/osdata/1808165-isequalto.md)
- [isEqualTo(const OSString *)](kernel/osdata/1808172-isequalto.md)
- [isEqualTo(const void *, unsigned int)](kernel/osdata/1808178-isequalto.md)
- [serialize](kernel/osdata/1808185-serialize.md)
- [setCapacityIncrement](kernel/osdata/1808190-setcapacityincrement.md)
- [withBytes](kernel/osdata/1808195-withbytes.md)
- [withBytesNoCopy](kernel/osdata/1808197-withbytesnocopy.md)
- [withCapacity](kernel/osdata/1808204-withcapacity.md)
- [withData(const OSData *)](kernel/osdata/1808208-withdata.md)
- [withData(const OSData *, unsigned int, unsigned int)](kernel/osdata/1808211-withdata.md)
