Instance Method

showCorrectionIndicator(of:primaryString:alternativeStrings:forStringIn:view:completionHandler:)

Display a suitable user interface to indicate a correction may need to be made.

Declaration

func showCorrectionIndicator(of type: NSSpellChecker.CorrectionIndicatorType, primaryString: String, alternativeStrings: [String], forStringIn rectOfTypedString: NSRect, view: NSView, completionHandler completionBlock: ((String?) -> Void)? = nil)

Parameters

type

The correction type to display. See NSSpellChecker.CorrectionIndicatorType for possible values.

primaryString

The first string to be displayed, a correction or reversion according to the type of indicator.

alternativeStrings

An array of alternative strings to insert. This array may be empty.

rectOfTypedString

The rectangle of the typed text.

view

The view in which the correction indicator is to be displayed.

completionBlock

The Block called when a the correction indicator is dismissed.

The Block takes one argument:

acceptedString

The correction string the user excepted. If the user does not select a correction string nil is returned.

Discussion

Only one indicator at a time may be displayed for a given view, and the only thing a client may do with the indicator after displaying it is to dismiss it using the dismissCorrectionIndicator(for:) method.

See Also

Automatic Spelling Correction

func dismissCorrectionIndicator(for: NSView)

Dismisses the correction indicator for the specified view.

enum NSSpellChecker.CorrectionIndicatorType

Constants that allow an app to specify the correction indicator type displayed.