<!--
{
  "availability" : [
    "iOS: 6.0.0 -",
    "iPadOS: 6.0.0 -",
    "macCatalyst: 13.1.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "UIKit",
  "identifier" : "/documentation/UIKit/NSWritingDirectionAttributeName",
  "metadataVersion" : "0.1.0",
  "role" : "Global Variable",
  "symbol" : {
    "kind" : "Global Variable",
    "modules" : [
      "UIKit"
    ],
    "preciseIdentifier" : "c:@NSWritingDirectionAttributeName"
  },
  "title" : "NSWritingDirectionAttributeName"
}
-->

# NSWritingDirectionAttributeName

The writing direction of the text.

```
extern NSAttributedStringKey const NSWritingDirectionAttributeName;
```

## Overview

The value of this attribute is an <doc://com.apple.documentation/documentation/Foundation/NSArray> object containing <doc://com.apple.documentation/documentation/Foundation/NSNumber> objects representing the nested levels of writing direction overrides, in order from outermost to innermost.

This attribute provides a means to override the default bidirectional text algorithm, equivalent to using the Unicode bidi control characters `LRE`, `RLE`, `LRO`, or `RLO` paired with `PDF`, but as a higher-level attribute. (See [Unicode Standard Annex #9](http://unicode.org/reports/tr9/) for information about the Unicode bidi formatting codes.) The `NSWritingDirectionAttributeName` constant is a character-level attribute that provides a higher-level alternative to the inclusion of explicit bidirectional control characters in text. It is the `NSAttributedString` equivalent of the HTML markup using the `bdo` element with the `dir` attribute.

The values of the `NSNumber` objects should be `0`, `1`, `2`, or `3`, for `LRE`, `RLE`, `LRO`, or `RLO` respectively, and combinations of [`NSWritingDirection.leftToRight`](/documentation/UIKit/NSWritingDirection/leftToRight) and [`NSWritingDirection.rightToLeft`](/documentation/UIKit/NSWritingDirection/rightToLeft) with [`NSTextWritingDirection.embedding`](/documentation/UIKit/NSTextWritingDirection/embedding) or [`NSTextWritingDirection.override`](/documentation/UIKit/NSTextWritingDirection/override), as shown in the following table.

|Array `NSNumber` Values|Unicode Control Characters|Writing Direction Constants                                      |
|-----------------------|--------------------------|-----------------------------------------------------------------|
|`0`                    |`LRE`                     |`NSWritingDirectionLeftToRight | NSTextWritingDirectionEmbedding`|
|`1`                    |`RLE`                     |`NSWritingDirectionRightToLeft | NSTextWritingDirectionEmbedding`|
|`2`                    |`LRO`                     |`NSWritingDirectionLeftToRight | NSTextWritingDirectionOverride` |
|`3`                    |`RLO`                     |`NSWritingDirectionRightToLeft | NSTextWritingDirectionOverride` |

---

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)