<!--
{
  "availability" : [
    "macOS: 10.8.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSTextAlternatives",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSTextAlternatives"
  },
  "title" : "NSTextAlternatives"
}
-->

# NSTextAlternatives

A list of alternative strings for a piece of text.

```
class NSTextAlternatives
```

## Overview

[`NSTextAlternatives`](/documentation/AppKit/NSTextAlternatives) is an immutable value class that stores a list of alternatives for a piece of text and communicates the user’s selection of an alternative via a notification to your app. To support dictation, for example, you might use [`NSTextAlternatives`](/documentation/AppKit/NSTextAlternatives) to present a list of alternative interpretations for a word or phrase the user speaks. If the user chooses to replace the initial interpretation with an alternative, [`NSTextAlternatives`](/documentation/AppKit/NSTextAlternatives) notifies you of the choice so that you can update the text appropriately.

[`NSTextAlternatives`](/documentation/AppKit/NSTextAlternatives) instances are attached to attributed strings as the value of a text attribute, [`NSTextAlternativesAttributeName`](/documentation/AppKit/NSTextAlternativesAttributeName).

## Topics

### Initializing a Text Alternatives Object

[`init(primaryString:alternativeStrings:)`](/documentation/AppKit/NSTextAlternatives/init(primaryString:alternativeStrings:))

Initializes an `NSTextAlternatives` instance.

### Storing Alternative Text Strings

[`primaryString`](/documentation/AppKit/NSTextAlternatives/primaryString)

The text that was initially chosen as the input string.

[`alternativeStrings`](/documentation/AppKit/NSTextAlternatives/alternativeStrings)

An array of alternative possible interpretations that the user might select.

### Selecting an Alternative String

[`noteSelectedAlternativeString(_:)`](/documentation/AppKit/NSTextAlternatives/noteSelectedAlternativeString(_:))

Sent to the `NSTextAlternatives` object by the text view when the user chooses one of the alternative strings.

### Notifications

[`selectedAlternativeStringNotification`](/documentation/AppKit/NSTextAlternatives/selectedAlternativeStringNotification)

Posted when the user selects an alternate string.



---

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)