---
title: "withObjects(const OSObject *, const OSSymbol *, unsigned int, unsigned int)"
framework: kernel
role: pseudoSymbol
path: kernel/osdictionary/1808240-withobjects
---

# withObjects(const OSObject *, const OSSymbol *, unsigned int, unsigned int)

Creates and initializes an OSDictionary populated with keys and objects provided.

## Declaration

```occ
static OSDictionary * withObjects( 
 const OSObject *objects[], 
 const OSSymbol *keys[], 
 unsigned int count, 
 unsigned int capacity = 0); 
```

## Parameters

- `objects`: A C array of OSMetaClassBase-derived objects.
- `keys`: A C array of OSSymbol keys for the corresponding objects in objects.
- `count`: The number of keys and objects to be placed into the dictionary.
- `capacity`: The initial storage capacity of the new dictionary object. If 0, count is used; otherwise this value must be greater than or equal to count.

## Return Value

Return Value An instance of OSDictionary containing the key/object pairs provided, with a retain count of 1; NULL on failure.

## Overview

Overview objects and keys must be non-NULL, and count must be nonzero. If capacity is nonzero, it must be greater than or equal to count. The new dictionary will grow as needed to accommodate more key/object pairs (unlikeCFMutableDictionary, for which the initial capacity is a hard limit).

## See Also

### Miscellaneous

- [copyCollection](kernel/osdictionary/1808081-copycollection.md)
- [ensureCapacity](kernel/osdictionary/1808087-ensurecapacity.md)
- [flushCollection](kernel/osdictionary/1808092-flushcollection.md)
- [free](kernel/osdictionary/1808101-free.md)
- [getCapacity](kernel/osdictionary/1808107-getcapacity.md)
- [getCapacityIncrement](kernel/osdictionary/1808116-getcapacityincrement.md)
- [getCount](kernel/osdictionary/1808124-getcount.md)
- [getObject](kernel/osdictionary/1808133-getobject.md)
- [getObject(const OSString *)](kernel/osdictionary/1808139-getobject.md)
- [getObject(const OSSymbol *)](kernel/osdictionary/1808148-getobject.md)
- [initWithCapacity](kernel/osdictionary/1808159-initwithcapacity.md)
- [initWithDictionary](kernel/osdictionary/1808166-initwithdictionary.md)
- [initWithObjects(const OSObject *, const OSString *, unsigned int, unsigned int)](kernel/osdictionary/1808177-initwithobjects.md)
- [initWithObjects(const OSObject *, const OSSymbol *, unsigned int, unsigned int)](kernel/osdictionary/1808181-initwithobjects.md)
- [isEqualTo](kernel/osdictionary/1808187-isequalto.md)
- [isEqualTo(const OSDictionary *)](kernel/osdictionary/1808191-isequalto.md)
- [isEqualTo(const OSDictionary *, const OSCollection *)](kernel/osdictionary/1808194-isequalto.md)
- [merge](kernel/osdictionary/1808198-merge.md)
- [removeObject](kernel/osdictionary/1808205-removeobject.md)
- [removeObject(const OSString *)](kernel/osdictionary/1808207-removeobject.md)
- [removeObject(const OSSymbol *)](kernel/osdictionary/1808209-removeobject.md)
- [serialize](kernel/osdictionary/1808214-serialize.md)
- [setCapacityIncrement](kernel/osdictionary/1808218-setcapacityincrement.md)
- [setObject](kernel/osdictionary/1808220-setobject.md)
- [setObject(const OSString *, const OSMetaClassBase *)](kernel/osdictionary/1808224-setobject.md)
- [setObject(const OSSymbol *, const OSMetaClassBase *)](kernel/osdictionary/1808227-setobject.md)
- [withCapacity](kernel/osdictionary/1808230-withcapacity.md)
- [withDictionary](kernel/osdictionary/1808234-withdictionary.md)
- [withObjects(const OSObject *, const OSString *, unsigned int, unsigned int)](kernel/osdictionary/1808237-withobjects.md)
