---
title: "enumerateRanges(_:)"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/nsindexset/enumerateranges(_:)"
---

# enumerateRanges(_:)

Executes a given block using each object in the index set, in the specified ranges.

## Declaration

```swift
func enumerateRanges(_ block: (NSRange, UnsafeMutablePointer<ObjCBool>) -> Void)
```

## Parameters

- `block`: The block to apply to elements in the index set. The block takes two arguments:

## Discussion

Discussion If the Block parameter is nil this method will raise an exception. This method executes synchronously.

## See Also

### Enumerating Index Set Content

- [enumerateRanges(in:options:using:)](foundation/nsindexset/enumerateranges(in:options:using:).md)
- [enumerateRanges(options:using:)](foundation/nsindexset/enumerateranges(options:using:).md)
