---
title: "init(range:)"
framework: foundation
role: symbol
role_heading: Initializer
path: "foundation/nscharacterset/init(range:)"
---

# init(range:)

Returns a character set containing characters with Unicode values in a given range.

## Declaration

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

## Parameters

- `aRange`: A range of Unicode values. aRange.location is the value of the first character to return; aRange.location + aRange.length – 1 is the value of the last.

## Return Value

Return Value A character set containing characters whose Unicode values are given by aRange. If aRange.length is 0, returns an empty character set.

## Discussion

Discussion This code excerpt creates a character set object containing the lowercase English alphabetic characters: NSRange lcEnglishRange; NSCharacterSet *lcEnglishLetters;   lcEnglishRange.location = (unsigned int)'a'; lcEnglishRange.length = 26; lcEnglishLetters = [NSCharacterSet characterSetWithRange:lcEnglishRange];

## See Also

### Creating a Custom Character Set

- [init(coder:)](foundation/nscharacterset/init(coder:).md)
- [init(charactersIn:)](foundation/nscharacterset/init(charactersin:).md)
- [NSOpenStepUnicodeReservedBase](foundation/1560803-nsopenstepunicodereservedbase.md)
