One Logo Pool Ball
Foundation · IOS API REFERENCE

AttributeScopes.FoundationAttributes.InflectionRuleAttribute

enum · iOS 15.0+ · SDK 27.1

@frozen enum InflectionRuleAttribute

A rule that affects how an attributed string performs automatic grammatical agreement. Most apps can rely on loading localized strings to perform automatic grammar agreement. Typically, strings in your app's strings files use the Markdown extension syntax to indicate portions of the string that may require inflection to agree grammatically. This transformation occurs when you load the attributed string with methods like `init(localized:options:table:bundle:locale:comment:)`. However, if the system lacks information about the words in the string, you may need to apply an inflection rule programmatically. For example, a social networking app may have gender information about other users that you want to apply at runtime. When performing manual inflection at runtime, you use an inflection rule to indicate to the system what portions of a string should be automatically edited, and what to match. Apply the ``AttributeScopes/FoundationAttributes/inflect`` attribute to set an ``InflectionRule`` on an ``AttributedString``, then call ``AttributedString/inflected()`` to perform the grammar agreement and produce an edited string. ```swift var string = AttributedString(localized: "They liked your post.") // The user who liked the post uses feminine pronouns. var morphology = Morphology() morphology.grammaticalGender = .feminine string.inflect = InflectionRule(morphology: morphology) let result = string.inflected() // result == "She liked your post." ```

Members (2)

get · iOS 15.0+

markdownName

TypeScript
static get markdownName(): string
Swift declaration
static let markdownName: String

The Markdown name associated with an attributed string key.

get · iOS 15.0+

name

TypeScript
static get nameValue(): string
Swift declaration
static let name: String

The name of the key.

Skipped declarations

No declarations were skipped in this snapshot.

All Foundation types →