One Logo Pool Ball
Foundation · IOS API REFERENCE

InflectionRule

enum · iOS 15.0+ · SDK 27.1

enum InflectionRule

A rule that affects how an attributed string performs automatic grammatical agreement. Use an inflection rule to add grammatical agreement to a localized string. To do this, set the ``InflectionRule`` attribute on an attributed string, then call the `inflected()` method on the attributed string. For example, the following code creates an attributed string that uses automatic grammatical agreement: ```swift func attributedText(for food: String) -> AttributedString { var string = AttributedString(localized: "\(food) was added to your order.") string.inflect = InflectionRule.automatic return string.inflected() } ```

Members (3)

static · iOS 15.0+

canInflect

TypeScript
static canInflect(language: string): boolean
Swift declaration
static func canInflect(language: String) -> Bool

Returns a Boolean value that indicates whether the rule can inflect a given language. - Parameter language: The language to apply inflection to, specified as a BCP 47 language code. - Returns: `true` if the rule can inflect the given language; otherwise, `false`.

init · iOS 15.0+

init

TypeScript
static init(morphology: Morphology): InflectionRule
Swift declaration
init(morphology: Morphology)

Creates an inflection rule with the given morphology. - Parameter morphology: The morphology to use for inflection.

get · iOS 15.0+

canInflectPreferredLocalization

TypeScript
static get canInflectPreferredLocalization(): boolean
Swift declaration
static var canInflectPreferredLocalization: Bool { get }

A Boolean value that indicates whether the rule can inflect the user's current preferred localization. This value doesn't change throughout the lifetime of a process.

Skipped declarations

No declarations were skipped in this snapshot.

All Foundation types →