---
title: "checkGrammar(of:startingAt:language:wrap:inSpellDocumentWithTag:details:)"
framework: appkit
role: symbol
role_heading: Instance Method
path: "appkit/nsspellchecker/checkgrammar(of:startingat:language:wrap:inspelldocumentwithtag:details:)"
---

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

Initiates a grammatical analysis of a given string.

## Declaration

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

Return Value Location of the first flagged grammatical unit.

## 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)
- [checkSpelling(of:startingAt:language:wrap:inSpellDocumentWithTag:wordCount:)](appkit/nsspellchecker/checkspelling(of:startingat:language:wrap:inspelldocumentwithtag:wordcount:).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)
