---
title: withObjects
framework: driverkit
role: symbol
role_heading: Static Method
path: driverkit/osarray/withobjects
---

# withObjects

Allocates an OSArray object with given members and preallocated capacity.

## Declaration

```occ
static OSArrayPtr withObjects(const OSObject **values, uint32_t count, uint32_t capacity);
```

## Parameters

- `values`: C-array pointer to members for the array.
- `count`: Count of members being added to the 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

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