---
title: withString
framework: driverkit
role: symbol
role_heading: Static Method
path: driverkit/osstring/withstring
---

# withString

Allocates an OSString object with a copy of an OString object.

## Declaration

```occ
static OSStringPtr withString(const OSString *aString);
```

## Parameters

- `aString`: OSString object to copy from. The string will be copied at the time of the call.

## Return Value

Return Value NULL on failure, otherwise the allocated OSString with reference count 1 to be released by the caller.

## Discussion

Discussion Allocates an OSString object with a copy of an OString object.

## See Also

### Creating a String

- [withCString](driverkit/osstring/withcstring-4wsql.md)
- [withCString](driverkit/osstring/withcstring-721oh.md)
- [withCStringNoCopy](driverkit/osstring/withcstringnocopy.md)
- [OSStringCreate](driverkit/osstringcreate.md)
- [free](driverkit/osstring/free.md)
