---
title: OSDictionary
framework: driverkit
role: symbol
role_heading: Class
path: driverkit/osdictionary
---

# OSDictionary

A container for a collection with elements that are key-value pairs.

## Declaration

```occ
class OSDictionary;
```

## Overview

Overview OSDictionary is a collection class for objects derived from OSObject. Storage and access are associative, based on keys that are uniqued OSObjects. OSString is commonly used as a key since it is uniqued. When adding an object to an OSDictionary, you provide a string identifier, which can then used to retrieve that object or remove it from the dictionary. Setting an object with a key that already has an associated object replaces the original object. You must generally cast retrieved objects from OSObject to the desired class using the OSDynamicCast macro. This macro returns the object cast to the desired class, or NULL if the object isn’t derived from that class. As with all DriverKit collection classes, OSDictionary retains objects added to it, and releases objects removed from it (or replaced). An OSDictionary also grows as necessary to accommodate new objects. OSArray provides no concurrency protection; it’s up to the usage context to provide any protection necessary.

## Topics

### Creating a Dictionary

- [withCapacity](driverkit/osdictionary/withcapacity.md)
- [withDictionary](driverkit/osdictionary/withdictionary.md)
- [withObjects](driverkit/osdictionary/withobjects.md)
- [OSDictionaryCreate](driverkit/osdictionarycreate.md)
- [merge](driverkit/osdictionary/merge.md)
- [free](driverkit/osdictionary/free.md)
- [flushCollection](driverkit/osdictionary/flushcollection.md)

### Accessing Keys and Values

- [getObject](driverkit/osdictionary/getobject-9ikoz.md)
- [getObject](driverkit/osdictionary/getobject-8k3ie.md)
- [setObject](driverkit/osdictionary/setobject-9b4z0.md)
- [setObject](driverkit/osdictionary/setobject-7q0u2.md)
- [removeObject](driverkit/osdictionary/removeobject-25qm5.md)
- [removeObject](driverkit/osdictionary/removeobject-156jh.md)
- [iterateObjects](driverkit/osdictionary/iterateobjects-9h89s.md)
- [iterateObjects](driverkit/osdictionary/iterateobjects-6cv0d.md)
- [OSDictionaryIterateObjectsBlock](driverkit/osdictionaryiterateobjectsblock.md)
- [OSDictionaryIterateObjectsCallback](driverkit/osdictionaryiterateobjectscallback.md)

### Getting and Setting Values

- [OSDictionaryGetValue](driverkit/osdictionarygetvalue.md)
- [OSDictionaryGetStringValue](driverkit/osdictionarygetstringvalue.md)
- [OSDictionaryGetUInt64Value](driverkit/osdictionarygetuint64value.md)
- [OSDictionarySetValue](driverkit/osdictionarysetvalue.md)
- [OSDictionarySetStringValue](driverkit/osdictionarysetstringvalue.md)
- [OSDictionarySetUInt64Value](driverkit/osdictionarysetuint64value.md)
- [OSDictionaryPtr](driverkit/osdictionaryptr.md)

### Inspecting a Dictionary

- [ensureCapacity](driverkit/osdictionary/ensurecapacity.md)
- [getCapacity](driverkit/osdictionary/getcapacity.md)
- [getCount](driverkit/osdictionary/getcount.md)
- [OSDictionaryGetCount](driverkit/osdictionarygetcount.md)

### Modifying the Dictionary Items

- [OSDictionaryApply](driverkit/osdictionaryapply.md)
- [OSDictionaryApplier](driverkit/osdictionaryapplier.md)

### Comparing Dictionaries

- [isEqualTo](driverkit/osdictionary/isequalto-3c1k0.md)
- [isEqualTo](driverkit/osdictionary/isequalto-2p9or.md)
- [isEqualTo](driverkit/osdictionary/isequalto-3kuk7.md)

## Relationships

### Inherits From

- [OSCollection](driverkit/oscollection.md)

## See Also

### Registry data types

- [OSArray](driverkit/osarray.md)
- [OSBoolean](driverkit/osboolean.md)
- [OSData](driverkit/osdata.md)
- [OSNumber](driverkit/osnumber.md)
- [OSString](driverkit/osstring.md)
- [OSSerialization](driverkit/osserialization.md)
- [OSCollection](driverkit/oscollection.md)
- [OSContainer](driverkit/oscontainer.md)
- [OSObject](driverkit/osobject.md)
- [OSSymbol](driverkit/ossymbol.md)
- [IOFixed](driverkit/iofixed.md)
