ixany ixany - 1 month ago 8
Swift Question

Converting a NSAttributedString into an NSString using Swift

I have a NSMutableAttributedString which i want to convert into a NSString and back.
it works fine in the following direction

var attributedString = NSMutableAttributedString(string: unattributedString)


... but i'm not able to get a String out of the attributedString. how does that work?

Answer

Use the string property on NSMutableAttributedString:

var attributedString = NSMutableAttributedString(string: "hello, world!")
var s = attributedString.string