---
title: withCStringNoCopy
framework: kernel
role: pseudoSymbol
path: kernel/osstring/1808304-withcstringnocopy
---

# withCStringNoCopy

Creates and initializes an immutable OSString that shares the provided C string buffer.

## Declaration

```occ
static OSString * withCStringNoCopy(
 const char *cString); 
```

## Parameters

- `cString`: The C string to reference.

## Return Value

Return Value An instance of OSString containing cString, and with a reference count of 1; NULL on failure.

## Overview

Overview An OSString object created with this function does not claim ownership of the C string, but shares it with the caller. When the caller determines that the OSString object has actually been freed, it can safely dispose of the data buffer. Conversely, if it frees the shared data buffer, it must not attempt to use the OSString object and should release it. An OSString object created with this function does not allow changing the string via setChar.

## See Also

### Miscellaneous

- [free](kernel/osstring/1808271-free.md)
- [getChar](kernel/osstring/1808273-getchar.md)
- [getCStringNoCopy](kernel/osstring/1808275-getcstringnocopy.md)
- [getLength](kernel/osstring/1808278-getlength.md)
- [initWithCString](kernel/osstring/1808281-initwithcstring.md)
- [initWithCStringNoCopy](kernel/osstring/1808284-initwithcstringnocopy.md)
- [initWithString](kernel/osstring/1808286-initwithstring.md)
- [isEqualTo(const char *)](kernel/osstring/1808288-isequalto.md)
- [isEqualTo(const OSData *)](kernel/osstring/1808292-isequalto.md)
- [isEqualTo(const OSMetaClassBase *)](kernel/osstring/1808295-isequalto.md)
- [isEqualTo(const OSString *)](kernel/osstring/1808297-isequalto.md)
- [serialize](kernel/osstring/1808298-serialize.md)
- [setChar](kernel/osstring/1808300-setchar.md)
- [withCString](kernel/osstring/1808301-withcstring.md)
- [withString](kernel/osstring/1808306-withstring.md)
