<!--
{
  "availability" : [
    "macOS: 10.5.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSSpellChecker/checkGrammar(of:startingAt:language:wrap:inSpellDocumentWithTag:details:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSSpellChecker(im)checkGrammarOfString:startingAt:language:wrap:inSpellDocumentWithTag:details:"
  },
  "title" : "checkGrammar(of:startingAt:language:wrap:inSpellDocumentWithTag:details:)"
}
-->

# checkGrammar(of:startingAt:language:wrap:inSpellDocumentWithTag:details:)

Initiates a grammatical analysis of a given string.

```
func checkGrammar(of stringToCheck: String, startingAt startingOffset: Int, language: String?, wrap wrapFlag: Bool, inSpellDocumentWithTag tag: Int, details: AutoreleasingUnsafeMutablePointer<NSArray?>?) -> NSRange
```

## Parameters

`stringToCheck`

String to analyze.

`startingOffset`

Location within `string` at which to start the analysis.

`language`

Language use in `string`. When `nil`, the language selected in the Spelling panel is used.

`wrapFlag`

<doc://com.apple.documentation/documentation/Swift/true> to specify that the analysis continue to the beginning of string when the end is reached.

    <doc://com.apple.documentation/documentation/Swift/false>     to have the analysis stop at the end of string.

`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.

`details`

On output, dictionaries describing grammar-analysis details within the flagged grammatical unit. See the <doc://com.apple.documentation/documentation/Foundation/NSSpellServer> class for information about these dictionaries.

## Return Value

Location of the first flagged grammatical unit.

---

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)