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

# enumerateRanges(in:options:using:)

Enumerates over the ranges in the range of objects using the block

## Declaration

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

## Parameters

- `range`: The range of items to enumerate. If the range intersects a range of the receiver’s indexes, then that intersection will be passed to the block.
- `opts`: A bitmask that specifies the doc://com.apple.foundation/documentation/Foundation/NSEnumerationOptions for the enumeration.
- `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(_:)](foundation/nsindexset/enumerateranges(_:).md)
- [enumerateRanges(options:using:)](foundation/nsindexset/enumerateranges(options:using:).md)
