<!--
{
  "availability" : [
    "macCatalyst: 13.0.0 -",
    "macOS: 10.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/NSSpellServerDelegate/spellServer(_:findMisspelledWordIn:language:wordCount:countOnly:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(pl)NSSpellServerDelegate(im)spellServer:findMisspelledWordInString:language:wordCount:countOnly:"
  },
  "title" : "spellServer(_:findMisspelledWordIn:language:wordCount:countOnly:)"
}
-->

# spellServer(_:findMisspelledWordIn:language:wordCount:countOnly:)

Asks the delegate to search for a misspelled word in a given string, using the specified language, and marking the first misspelled word found by returning its range within the string.

```
optional func spellServer(_ sender: NSSpellServer, findMisspelledWordIn stringToCheck: String, language: String, wordCount: UnsafeMutablePointer<Int>, countOnly: Bool) -> NSRange
```

## Parameters

`sender`

The `NSSpellServer` object that sent this message.

`stringToCheck`

The string to search for the misspelled word.

`language`

The language to use for the search.

`wordCount`

On output, returns by reference the number of words from the beginning of the string object until the misspelled word (or the end of string).

`countOnly`

If <doc://com.apple.documentation/documentation/Swift/true>, the method only counts the words in the string object and does not spell checking.

## Return Value

The range of the misspelled word within the given string.

## Discussion

Send [`isWord(inUserDictionaries:caseSensitive:)`](/documentation/Foundation/NSSpellServer/isWord(inUserDictionaries:caseSensitive:)) to the spelling server to determine if the word exists in the user’s language dictionaries.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)