---
title: "setSpellingState(_:range:)"
framework: appkit
role: symbol
role_heading: Instance Method
path: "appkit/nstextview/setspellingstate(_:range:)"
---

# setSpellingState(_:range:)

Sets the spelling state, which controls the display of the spelling and grammar indicators on the given text range.

## Declaration

```swift
func setSpellingState(_ value: Int, range charRange: NSRange)
```

## Parameters

- `value`: The spelling state value to set. Possible values, for the temporary attribute on the layout manager using the key NSSpellingStateAttributeName, are: doc://com.apple.appkit/documentation/AppKit/NSSpellingState/NSSpellingStateSpellingFlag to highlight spelling issues. doc://com.apple.appkit/documentation/AppKit/NSSpellingState/NSSpellingStateGrammarFlag to highlight grammar issues.
- `charRange`: The character range over which to set the given spelling state.

## Discussion

Discussion May be called or overridden to control setting of spelling and grammar indicators on text, used to highlight portions of the text that are flagged for spelling or grammar issues.

## See Also

### Working with the spelling checker

- [isContinuousSpellCheckingEnabled](appkit/nstextview/iscontinuousspellcheckingenabled.md)
- [spellCheckerDocumentTag](appkit/nstextview/spellcheckerdocumenttag.md)
- [toggleContinuousSpellChecking(_:)](appkit/nstextview/togglecontinuousspellchecking(_:).md)
- [isGrammarCheckingEnabled](appkit/nstextview/isgrammarcheckingenabled.md)
- [toggleGrammarChecking(_:)](appkit/nstextview/togglegrammarchecking(_:).md)
