Instance Method


Sets an array of candidate objects to be displayed in the candidate list bar item.


func setCandidates(_ candidates: [CandidateType], forSelectedRange selectedRange: NSRange, in originalString: String?)



The array of candidates you wish to display in the candidate list item.


A range (NSRange) within the string that the candidates represent.


The original string from which the candidate list was derived.


The item uses the block in the attributedStringForCandidate property to convert each candidate in the array into an attributed string. If the value of the attributedStringForCandidate property is nil then NSCandidateListTouchBarItem can format candidates of type NSString, NSAttributedString, and NSTextCheckingResult.

See Also

Populating the Candidate List

var candidates: [CandidateType]

The array of candidate objects previously set by setCandidates(_:forSelectedRange:in:).

var attributedStringForCandidate: ((CandidateType, Int) -> NSAttributedString)?

A block that converts a candidate object into an attributed string for display in the candidate list item.

var allowsTextInputContextCandidates: Bool

A Boolean value that specifies whether a candidate list item displays candidates from text input providers.