---
title: withObjects
framework: Kernel
role: symbol
role_heading: Type Method
platforms: [driverkit 19.0+, macOS 10.15+]
path: kernel/osdictionary/3180909-withobjects
---

# withObjects

Allocates an OSDictionary object with given members and preallocated capacity.

## Declaration

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

```occ
static OSPtr<OSDictionary> withObjects(const OSObject *objects[], const OSString *keys[], unsigned int count, unsigned int capacity);
```

## Parameters

- `values`: C-array pointer to values for the dictionary.
- `keys`: C-array pointer to keys for the dictionary.
- `count`: Count of members being added to the dictionary.
- `capacity`: Count of allocated capacity for members in dictionary.

## Return Value

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

## See Also

### Creating a Dictionary

- [withCapacity](kernel/osdictionary/3180907-withcapacity.md)
- [withDictionary](kernel/osdictionary/3180908-withdictionary.md)
- [merge](kernel/osdictionary/3180904-merge.md)
- [free](kernel/osdictionary/3180898-free.md)
- [flushCollection](kernel/osdictionary/3180897-flushcollection.md)
