<!--
{
  "availability" : [
    "macOS: 10.6.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSWritingDirectionAttributeName",
  "metadataVersion" : "0.1.0",
  "role" : "Global Variable",
  "symbol" : {
    "kind" : "Global Variable",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:@NSWritingDirectionAttributeName"
  },
  "title" : "NSWritingDirectionAttributeName"
}
-->

# NSWritingDirectionAttributeName

The writing direction of the text.

```
extern NSAttributedStringKey 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 `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/AppKit/NSWritingDirection/leftToRight) and [`NSWritingDirection.rightToLeft`](/documentation/AppKit/NSWritingDirection/rightToLeft) with [`NSTextWritingDirectionEmbedding`](/documentation/AppKit/NSTextWritingDirectionEmbedding) or [`NSTextWritingDirectionOverride`](/documentation/AppKit/NSTextWritingDirectionOverride), 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)