How to use NSWritingDirectionAttributeName in swift?

How to use NSWritingDirectionAttributeName in swift?

I have this code in Obj-c:

  • Best way to access all movie frames in iOS
  • How do you release an MTAudioProcessingTap?
  • Trigger an event / method when UIWindow RootViewController changes SWIFT
  • How to repeat local notifications on specific days of the week (iOS Swift 3)
  • Where to set environment variables for app?
  • iOS game Localization with String Format
  • attrString = [[NSMutableAttributedString alloc] initWithString:title attributes:@{NSFontAttributeName:[UIFont fontAwesomeFontOfSize:24], NSForegroundColorAttributeName:kHJColorIcon, NSWritingDirectionAttributeName:@[@(NSWritingDirectionRightToLeft | NSTextWritingDirectionOverride)]}];

    which is working great!

    Now I need to use the same code in another place but in swift language.

    I tried several ways but I get errors.
    enter image description here

    2 Solutions Collect From Internet About “How to use NSWritingDirectionAttributeName in swift?”

    The key NSWritingDirectionAttributeName expects numeric values so use the raw values

    [NSWritingDirectionAttributeName : [NSWritingDirection.LeftToRight.rawValue | NSTextWritingDirection.Override.rawValue]]

    The key NSWritingDirectionAttributeName need the Numeric value so use in addition of rawValue on your function, try this

    let attrString = NSMutableAttributedString(string: "Karthik Test",
                     attributes: [NSFontAttributeName: UIFont.systemFontOfSize(24),
                                  NSWritingDirectionAttributeName:[NSWritingDirection.RightToLeft.rawValue |