<!--
{
  "availability" : [
    "iOS: -",
    "iPadOS: -",
    "macCatalyst: -",
    "macOS: -",
    "tvOS: -",
    "visionOS: -",
    "watchOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreFoundation",
  "identifier" : "/documentation/CoreFoundation/CFBitVector",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "Core Foundation"
    ],
    "preciseIdentifier" : "c:@T@CFBitVectorRef"
  },
  "title" : "CFBitVector"
}
-->

# CFBitVector

```
class CFBitVector
```

## Overview

CFBitVector and its derived mutable type, [`CFMutableBitVector`](/documentation/CoreFoundation/CFMutableBitVector), manage ordered collections of bit values, which are either `0` or `1`. CFBitVector creates static bit vectors and CFMutableBitVector creates dynamic bit vectors.

## Topics

### Creating a Bit Vector

[`CFBitVectorCreate(_:_:_:)`](/documentation/CoreFoundation/CFBitVectorCreate(_:_:_:))

Creates an immutable bit vector from a block of memory.

[`CFBitVectorCreateCopy(_:_:)`](/documentation/CoreFoundation/CFBitVectorCreateCopy(_:_:))

Creates an immutable bit vector that is a copy of another bit vector.

### Getting Information About a Bit Vector

[`CFBitVectorContainsBit(_:_:_:)`](/documentation/CoreFoundation/CFBitVectorContainsBit(_:_:_:))

Returns whether a bit vector contains a particular bit value.

[`CFBitVectorGetBitAtIndex(_:_:)`](/documentation/CoreFoundation/CFBitVectorGetBitAtIndex(_:_:))

Returns the bit value at a given index in a bit vector.

[`CFBitVectorGetBits(_:_:_:)`](/documentation/CoreFoundation/CFBitVectorGetBits(_:_:_:))

Returns the bit values in a range of indices in a bit vector.

[`CFBitVectorGetCount(_:)`](/documentation/CoreFoundation/CFBitVectorGetCount(_:))

Returns the number of bit values in a bit vector.

[`CFBitVectorGetCountOfBit(_:_:_:)`](/documentation/CoreFoundation/CFBitVectorGetCountOfBit(_:_:_:))

Counts the number of times a certain bit value occurs within a range of bits in a bit vector.

[`CFBitVectorGetFirstIndexOfBit(_:_:_:)`](/documentation/CoreFoundation/CFBitVectorGetFirstIndexOfBit(_:_:_:))

Locates the first occurrence of a certain bit value within a range of bits in a bit vector.

[`CFBitVectorGetLastIndexOfBit(_:_:_:)`](/documentation/CoreFoundation/CFBitVectorGetLastIndexOfBit(_:_:_:))

Locates the last occurrence of a certain bit value within a range of bits in a bit vector.

### Getting the CFBitVector Type ID

[`CFBitVectorGetTypeID()`](/documentation/CoreFoundation/CFBitVectorGetTypeID())

Returns the type identifier for the CFBitVector opaque type.

### Data Types

[`CFBit`](/documentation/CoreFoundation/CFBit)

A binary value of either `0` or `1`.

## See Also

  [Collections Programming Topics for Core Foundation](https://developer.apple.com/library/archive/documentation/CoreFoundation/Conceptual/CFCollections/CFCollections.html#//apple_ref/doc/uid/10000124i)



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)