---
title: attributedStringForCandidate
framework: appkit
role: symbol
role_heading: Instance Property
path: appkit/nscandidatelisttouchbaritem/attributedstringforcandidate
---

# attributedStringForCandidate

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

## Declaration

```swift
var attributedStringForCandidate: ((CandidateType, Int) -> NSAttributedString)? { get set }
```

## Discussion

Discussion This property is not required if the object type of your candidates is NSString, NSAttributedString, or NSTextCheckingResult. The default value of this property is nil. If the attributed string you return does not specify font or foregroundColor then the candidate is displayed with the standard appearance font and color.

## See Also

### Populating the candidate list

- [setCandidates(_:forSelectedRange:in:)](appkit/nscandidatelisttouchbaritem/setcandidates(_:forselectedrange:in:).md)
- [candidates](appkit/nscandidatelisttouchbaritem/candidates.md)
- [allowsTextInputContextCandidates](appkit/nscandidatelisttouchbaritem/allowstextinputcontextcandidates.md)
