---
title: OSArray
framework: driverkit
role: symbol
role_heading: Class
path: driverkit/osarray
---

# OSArray

A container for an ordered, random-access collection of objects.

## Declaration

```occ
class OSArray;
```

## Overview

Overview OSArray is a collection class for objects derived from OSObject. Storage and access are by array index. 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, OSArray retains objects added to it, and releases objects removed from it (or replaced). An OSArray 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 an Array

- [withArray](driverkit/osarray/witharray.md)
- [withCapacity](driverkit/osarray/withcapacity.md)
- [withObjects](driverkit/osarray/withobjects.md)
- [OSArrayCreate](driverkit/osarraycreate.md)
- [merge](driverkit/osarray/merge.md)
- [free](driverkit/osarray/free.md)
- [flushCollection](driverkit/osarray/flushcollection.md)

### Accessing Elements

- [getObject](driverkit/osarray/getobject.md)
- [getLastObject](driverkit/osarray/getlastobject.md)
- [getNextIndexOfObject](driverkit/osarray/getnextindexofobject.md)
- [setObject](driverkit/osarray/setobject-3bore.md)
- [setObject](driverkit/osarray/setobject-4ys3x.md)
- [iterateObjects](driverkit/osarray/iterateobjects.md)
- [replaceObject](driverkit/osarray/replaceobject.md)
- [removeObject](driverkit/osarray/removeobject.md)
- [OSArrayAppendValue](driverkit/osarrayappendvalue.md)
- [OSArrayReplaceValue](driverkit/osarrayreplacevalue.md)

### Getting and Setting Values

- [OSArrayGetValue](driverkit/osarraygetvalue.md)
- [OSArrayGetStringValue](driverkit/osarraygetstringvalue.md)
- [OSArrayGetUInt64Value](driverkit/osarraygetuint64value.md)
- [OSArraySetValue](driverkit/osarraysetvalue.md)
- [OSArraySetStringValue](driverkit/osarraysetstringvalue.md)
- [OSArraySetUInt64Value](driverkit/osarraysetuint64value.md)
- [Array Indices](driverkit/3180989-array_indices.md)
- [OSArrayPtr](driverkit/osarrayptr.md)

### Inspecting an Array

- [getCount](driverkit/osarray/getcount.md)
- [getCapacity](driverkit/osarray/getcapacity.md)
- [ensureCapacity](driverkit/osarray/ensurecapacity.md)
- [OSArrayGetCount](driverkit/osarraygetcount.md)

### Modifying the Array Contents

- [OSArrayApply](driverkit/osarrayapply.md)
- [OSArrayApplier](driverkit/osarrayapplier.md)

### Comparing Arrays

- [isEqualTo](driverkit/osarray/isequalto-5w7om.md)
- [isEqualTo](driverkit/osarray/isequalto-93qxy.md)

## Relationships

### Inherits From

- [OSCollection](driverkit/oscollection.md)

### Inherited By

- [OSSet](driverkit/osset.md)

## See Also

### Registry data types

- [OSDictionary](driverkit/osdictionary.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)
