---
title: "checkSpelling(of:startingAt:language:wrap:inSpellDocumentWithTag:wordCount:)"
framework: appkit
role: symbol
role_heading: Instance Method
path: "appkit/nsspellchecker/checkspelling(of:startingat:language:wrap:inspelldocumentwithtag:wordcount:)"
---

# checkSpelling(of:startingAt:language:wrap:inSpellDocumentWithTag:wordCount:)

Starts the search for a misspelled word in a string starting at specified offset within the string.

## Declaration

```swift
func checkSpelling(of stringToCheck: String, startingAt startingOffset: Int, language: String?, wrap wrapFlag: Bool, inSpellDocumentWithTag tag: Int, wordCount: UnsafeMutablePointer<Int>?) -> NSRange
```

## Parameters

- `stringToCheck`: The string object containing the words to spellcheck.
- `startingOffset`: The offset within stringToCheck at which to begin spellchecking.
- `language`: The language of the words in the string. If language is nil, or if you obtain the value by sending doc://com.apple.appkit/documentation/AppKit/NSSpellChecker/language() to self, the current selection in the Spelling panel’s pop-up menu is used. Do not pass in an empty string for language.
- `wrapFlag`: doc://com.apple.documentation/documentation/Swift/true to indicate that spell checking should continue at the beginning of the string when the end of the string is reached; doc://com.apple.documentation/documentation/Swift/false to indicate that spellchecking should stop at the end of the document.
- `tag`: An identifier unique within the application used to inform the spell checker which document that text is associated, potentially for many purposes, not necessarily just for ignored words. A value of 0 can be passed in for text not associated with a particular document.
- `wordCount`: Returns by indirection a count of the words spell-checked up to and including the first error (if any), or -1 if the spell checker fails or does not support word counting. Specify NULL if you do not want this word count.

## Return Value

Return Value The range of the first misspelled word and optionally (and by reference) the count of words spellchecked in the string in wordCount.

## See Also

### Checking Strings for Spelling and Grammar

- [countWords(in:language:)](appkit/nsspellchecker/countwords(in:language:).md)
- [checkSpelling(of:startingAt:)](appkit/nsspellchecker/checkspelling(of:startingat:).md)
- [checkGrammar(of:startingAt:language:wrap:inSpellDocumentWithTag:details:)](appkit/nsspellchecker/checkgrammar(of:startingat:language:wrap:inspelldocumentwithtag:details:).md)
- [check(_:range:types:options:inSpellDocumentWithTag:orthography:wordCount:)](appkit/nsspellchecker/check(_:range:types:options:inspelldocumentwithtag:orthography:wordcount:).md)
- [requestChecking(of:range:types:options:inSpellDocumentWithTag:completionHandler:)](appkit/nsspellchecker/requestchecking(of:range:types:options:inspelldocumentwithtag:completionhandler:).md)
- [guesses(forWordRange:in:language:inSpellDocumentWithTag:)](appkit/nsspellchecker/guesses(forwordrange:in:language:inspelldocumentwithtag:).md)
