countWords(in:language:)
Returns the number of words in the specified string.
Declaration
func countWords(in stringToCount: String, language: String?) -> IntParameters
- stringToCount:
The string to count the words in.
- language:
The language of the string.
Return Value
The number of words in the string or -1 if word counting is unavailable or has not occurred for some reason.
Discussion
If language is nil, the current selection in the Spelling panel’s pop-up menu is used.
See Also
Checking Strings for Spelling and Grammar
checkSpelling(of:startingAt:)checkSpelling(of:startingAt:language:wrap:inSpellDocumentWithTag:wordCount:)checkGrammar(of:startingAt:language:wrap:inSpellDocumentWithTag:details:)check(_:range:types:options:inSpellDocumentWithTag:orthography:wordCount:)requestChecking(of:range:types:options:inSpellDocumentWithTag:completionHandler:)guesses(forWordRange:in:language:inSpellDocumentWithTag:)