---
title: withArray
framework: driverkit
role: symbol
role_heading: Static Method
path: driverkit/osarray/witharray
---

# withArray

Allocates an OSArray object with given members and preallocated capacity.

## Declaration

```occ
static OSArrayPtr withArray(const OSArray *array, uint32_t capacity);
```

## Parameters

- `array`: Array object containing members for the new array.
- `capacity`: Count of allocated capacity for members in array.

## Return Value

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

## See Also

### Creating an Array

- [withCapacity](driverkit/osarray/withcapacity.md)
- [withObjects](driverkit/osarray/withobjects.md)
- [OSArrayCreate](driverkit/osarraycreate.md)
- [merge](driverkit/osarray/merge.md)
- [free](driverkit/osarray/free.md)
- [flushCollection](driverkit/osarray/flushcollection.md)
