<!--
{
  "availability" : [
    "iOS: 2.0.0 -",
    "iPadOS: 2.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.0.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/NSFastEnumeration",
  "metadataVersion" : "0.1.0",
  "role" : "Protocol",
  "symbol" : {
    "kind" : "Protocol",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(pl)NSFastEnumeration"
  },
  "title" : "NSFastEnumeration"
}
-->

# NSFastEnumeration

A protocol that objects adopt to support fast enumeration.

```
protocol NSFastEnumeration
```

## Overview

The abstract class [`NSEnumerator`](/documentation/Foundation/NSEnumerator) provides a convenience implementation that uses [`nextObject()`](/documentation/Foundation/NSEnumerator/nextObject()) to return items one at a time.

## Topics

### Enumeration

[`-  countByEnumeratingWithState:objects:count:`](/documentation/Foundation/NSFastEnumeration/countByEnumerating(with:objects:count:))

Returns by reference a C array of objects over which the sender should iterate, and as the return value the number of objects in the array.

### Constants

[`NSFastEnumerationState`](/documentation/Foundation/NSFastEnumerationState)

This defines the structure used as contextual information in the [`NSFastEnumeration`](/documentation/Foundation/NSFastEnumeration) protocol.

## Relationships

### Conforming Types

[`NSMapTable`](/documentation/Foundation/NSMapTable)

[`NSArray`](/documentation/Foundation/NSArray)

[`NSOrderedCollectionDifference`](/documentation/Foundation/NSOrderedCollectionDifference)

[`NSSet`](/documentation/Foundation/NSSet)

[`NSHashTable`](/documentation/Foundation/NSHashTable)

[`NSPointerArray`](/documentation/Foundation/NSPointerArray)

[`NSDictionary`](/documentation/Foundation/NSDictionary)

[`NSMutableSet`](/documentation/Foundation/NSMutableSet)

[`NSEnumerator`](/documentation/Foundation/NSEnumerator)

[`NSMutableDictionary`](/documentation/Foundation/NSMutableDictionary)

[`NSOrderedSet`](/documentation/Foundation/NSOrderedSet)

[`NSMutableArray`](/documentation/Foundation/NSMutableArray)

[`NSMutableOrderedSet`](/documentation/Foundation/NSMutableOrderedSet)

[`DirectoryEnumerator`](/documentation/Foundation/FileManager/DirectoryEnumerator)

[`NSCountedSet`](/documentation/Foundation/NSCountedSet)

---

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)