<!--
{
  "availability" : [
    "iOS: 15.0.0 -",
    "iPadOS: 15.0.0 -",
    "macCatalyst: 15.0.0 -",
    "macOS: 12.0.0 -",
    "tvOS: 15.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 8.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/NSInflectionRule",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSInflectionRule"
  },
  "title" : "NSInflectionRule"
}
-->

# NSInflectionRule

A rule that affects how an attributed string performs automatic grammatical agreement.

```
@interface NSInflectionRule : NSObject
```

## Overview

Most apps can rely on loading localized strings to perform automatic grammar agreement. Typically, 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 `NSLocalizedAttributedString`.

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. Add the attribute [`inflectionRule`](/documentation/Foundation/NSAttributedString/Key/inflectionRule) with an [`NSInflectionRule`](/documentation/Foundation/NSInflectionRule) on an [`NSAttributedString`](/documentation/Foundation/NSAttributedString), then call [`inflecting()`](/documentation/Foundation/NSAttributedString/inflecting()) to perform the grammar agreement and produce an edited string.

## Topics

### Performing Automatic Inflection

[`automaticRule`](/documentation/Foundation/NSInflectionRule/automaticRule)

An inflection rule that performs automatic grammar agreement with default transformations.

### Determining Availability

[`canInflectLanguage:`](/documentation/Foundation/NSInflectionRule/canInflectLanguage:)

Returns a Boolean value that indicates whether the rule can inflect a given language.

[`canInflectPreferredLocalization`](/documentation/Foundation/NSInflectionRule/canInflectPreferredLocalization)

A Boolean value that indicates whether the rule can inflect the user’s current preferred localization.



---

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)