Contents

countWords(in:language:)

Returns the number of words in the specified string.

Declaration

func countWords(in stringToCount: String, language: String?) -> Int

Parameters

  • 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