OSArray provides an indexed store of objects.
- macOS 10.0+
- Mac Catalyst 13.0+
OSArray is a container for Libkern C++ objects (those derived from OSMetaClassBase, in particular OSObject). Storage and access are by array index.
You must generally cast retrieved objects from
OSObject to the desired class using OSDynamicCast. This macro returns the object cast to the desired class, or
NULL if the object isn't derived from that class.
As with all Libkern collection classes, OSArray retains objects added to it, and releases objects removed from it (or replaced). An OSArray also grows as necessary to accommodate new objects, unlike Core Foundation collections (it does not, however, shrink).
With very few exceptions in the I/O Kit, all Libkern-based C++ classes, functions, and macros are unsafe to use in a primary interrupt context. Consult the I/O Kit documentation related to primary interrupts for more information.
OSArray provides no concurrency protection; it's up to the usage context to provide any protection necessary. Some portions of the I/O Kit, such as IORegistryEntry, handle synchronization via defined member functions for setting properties.