---
title: CFArray
framework: corefoundation
role: symbol
role_heading: Class
path: corefoundation/cfarray
---

# CFArray

## Declaration

```swift
class CFArray
```

## Overview

Overview CFArray and its derived mutable type, CFMutableArray, manage ordered collections of values called arrays. CFArray creates static arrays and CFMutableArray creates dynamic arrays. You create a static array object using either the CFArrayCreate(_:_:_:_:) or CFArrayCreateCopy(_:_:) function. These functions return an array containing the values you pass in as arguments. (Note that arrays can’t contain NULL pointers; in most cases, though, you can use the kCFNull constant instead.) Values are not copied but retained using the retain callback provided when an array was created. Similarly, when a value is removed from an array, it is released using the release callback. CFArray’s two primitive functions CFArrayGetCount(_:) and CFArrayGetValueAtIndex(_:_:) provide the basis for all other functions in its interface. The CFArrayGetCount(_:) function returns the number of elements in an array; CFArrayGetValueAtIndex(_:_:) gives you access to an array’s elements by index, with index values starting at 0. A number of CFArray functions allow you to operate over a range of values in an array, for example CFArrayApplyFunction(_:_:_:_:) lets you apply a function to values in an array, and CFArrayBSearchValues(_:_:_:_:_:) searches an array for the value that matches its parameter. Recall that a range is defined as {start, length}, therefore to operate over the entire array the range you supply should be {0, N} (where N is the count of the array). CFArray is “toll-free bridged” with its Cocoa Foundation counterpart, NSArray. This means that the Core Foundation type is interchangeable in function or method calls with the bridged Foundation object. Therefore, in a method where you see an NSArray * parameter, you can pass in a CFArrayRef, and in a function where you see a CFArrayRef parameter, you can pass in an NSArray instance. This also applies to concrete subclasses of NSArray. See Toll-Free Bridged Types for more information on toll-free bridging.

## Topics

### Creating an Array

- [CFArrayCreate(_:_:_:_:)](corefoundation/cfarraycreate(_:_:_:_:).md)
- [CFArrayCreateCopy(_:_:)](corefoundation/cfarraycreatecopy(_:_:).md)

### Examining an Array

- [CFArrayBSearchValues(_:_:_:_:_:)](corefoundation/cfarraybsearchvalues(_:_:_:_:_:).md)
- [CFArrayContainsValue(_:_:_:)](corefoundation/cfarraycontainsvalue(_:_:_:).md)
- [CFArrayGetCount(_:)](corefoundation/cfarraygetcount(_:).md)
- [CFArrayGetCountOfValue(_:_:_:)](corefoundation/cfarraygetcountofvalue(_:_:_:).md)
- [CFArrayGetFirstIndexOfValue(_:_:_:)](corefoundation/cfarraygetfirstindexofvalue(_:_:_:).md)
- [CFArrayGetLastIndexOfValue(_:_:_:)](corefoundation/cfarraygetlastindexofvalue(_:_:_:).md)
- [CFArrayGetValues(_:_:_:)](corefoundation/cfarraygetvalues(_:_:_:).md)
- [CFArrayGetValueAtIndex(_:_:)](corefoundation/cfarraygetvalueatindex(_:_:).md)

### Applying a Function to Elements

- [CFArrayApplyFunction(_:_:_:_:)](corefoundation/cfarrayapplyfunction(_:_:_:_:).md)

### Getting the CFArray Type ID

- [CFArrayGetTypeID()](corefoundation/cfarraygettypeid().md)

### Callbacks

- [CFArrayApplierFunction](corefoundation/cfarrayapplierfunction.md)
- [CFArrayCopyDescriptionCallBack](corefoundation/cfarraycopydescriptioncallback.md)
- [CFArrayEqualCallBack](corefoundation/cfarrayequalcallback.md)
- [CFArrayReleaseCallBack](corefoundation/cfarrayreleasecallback.md)
- [CFArrayRetainCallBack](corefoundation/cfarrayretaincallback.md)

### Data Types

- [CFArrayCallBacks](corefoundation/cfarraycallbacks.md)

### Constants

- [Predefined Callback Structures](corefoundation/predefined-callback-structures.md)

## Relationships

### Inherited By

- [CFMutableArray](corefoundation/cfmutablearray.md)

### Conforms To

- [Equatable](swift/equatable.md)
- [Hashable](swift/hashable.md)

## See Also

### Related Documentation

- [Property List Programming Topics for Core Foundation](apple-archive/documentation/CoreFoundation/Conceptual/CFPropertyLists.md)
- [Collections Programming Topics for Core Foundation](apple-archive/documentation/CoreFoundation/Conceptual/CFCollections.md)

### Opaque Types

- [CFAllocator](corefoundation/cfallocator.md)
- [CFAttributedString](corefoundation/cfattributedstring.md)
- [CFBag](corefoundation/cfbag.md)
- [CFBinaryHeap](corefoundation/cfbinaryheap.md)
- [CFBitVector](corefoundation/cfbitvector.md)
- [CFBoolean](corefoundation/cfboolean.md)
- [CFBundle](corefoundation/cfbundle.md)
- [CFCalendar](corefoundation/cfcalendar.md)
- [CFCharacterSet](corefoundation/cfcharacterset.md)
- [CFData](corefoundation/cfdata.md)
- [CFDate](corefoundation/cfdate.md)
- [CFDateFormatter](corefoundation/cfdateformatter.md)
- [CFDictionary](corefoundation/cfdictionary.md)
- [CFError](corefoundation/cferror.md)
- [CFFileDescriptor](corefoundation/cffiledescriptor.md)
