OSDictionary
A container for a collection with elements that are key-value pairs.
Declaration
class OSDictionary;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
Accessing Keys and Values
getObjectgetObjectsetObjectsetObjectremoveObjectremoveObjectiterateObjectsiterateObjectsOSDictionaryIterateObjectsBlockOSDictionaryIterateObjectsCallback
Getting and Setting Values
OSDictionaryGetValueOSDictionaryGetStringValueOSDictionaryGetUInt64ValueOSDictionarySetValueOSDictionarySetStringValueOSDictionarySetUInt64ValueOSDictionaryPtr