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

# enumerateRanges(options:using:)

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

## Declaration

```swift
func enumerateRanges(options opts: NSEnumerationOptions = [], using block: (NSRange, UnsafeMutablePointer<ObjCBool>) -> Void)
```

## Parameters

- `opts`: A bitmask that specifies the doc://com.apple.foundation/documentation/Foundation/NSEnumerationOptions for the enumeration (whether it should be performed concurrently and whether it should be performed in reverse order).
- `block`: The block to apply to elements in the index set. The block takes two arguments:

## Discussion

Discussion By default, the enumeration starts with the first object and continues serially through the indexed set range to the last object in the range. You can specify NSEnumerationConcurrent and/or NSEnumerationReverse as enumeration options to modify this behavior. This method executes synchronously. important: If the Block parameter is nil this method will raise an exception.

## See Also

### Enumerating Index Set Content

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