<!--
{
  "availability" : [
    "macOS: 10.12.2 -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSCandidateListTouchBarItem/attributedStringForCandidate",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Property",
  "symbol" : {
    "kind" : "Instance Property",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSCandidateListTouchBarItem(py)attributedStringForCandidate"
  },
  "title" : "attributedStringForCandidate"
}
-->

# attributedStringForCandidate

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

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

## Discussion

This property is not required if the object type of your candidates is <doc://com.apple.documentation/documentation/Foundation/NSString>, <doc://com.apple.documentation/documentation/Foundation/NSAttributedString>, or <doc://com.apple.documentation/documentation/Foundation/NSTextCheckingResult>. The default value of this property is `nil`.

If the attributed string you return does not specify <doc://com.apple.documentation/documentation/Foundation/NSAttributedString/Key/font> or <doc://com.apple.documentation/documentation/Foundation/NSAttributedString/Key/foregroundColor> then the candidate is displayed with the standard appearance font and color.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)