---
title: "init(indexesIn:)"
framework: foundation
role: symbol
role_heading: Initializer
path: "foundation/nsindexset/init(indexesin:)"
---

# init(indexesIn:)

Initializes an allocated NSIndexSet object with an index range.

## Declaration

```swift
init(indexesIn range: NSRange)
```

## Parameters

- `range`: An index range. Must be in the range 0 .. NSNotFound - 1..

## Return Value

Return Value Initialized NSIndexSet object with indexRange.

## Discussion

Discussion This method raises an rangeException when indexRange would add an index that exceeds the maximum allowed value for unsigned integers. The resulting index set has a firstIndex equal to the location of indexRange, and a count equal to the length of indexRange. Specifying a zero-length range results in an empty index set. This method is a designated initializer for NSIndexSet.

## See Also

### Creating Index Sets

- [init(index:)](foundation/nsindexset/init(index:).md)
- [init(indexSet:)](foundation/nsindexset/init(indexset:).md)
