How to save an attributedStringValue to a String without losing attributes?

Hello.
My OS X document application updates a sequential file, containing several records separated by the new line special character. Each record contains several fields (strings) separated by a specific character.
I would like to save the value of a NSTextField allowing rich text in one of these fields. Therefore I need to convert a NSAttributedString to a String without losing its attributes.
Looking with Google I understand that I should use dataFromRange:documentAttributes:error: to create a NSData object,then getBytes with full length. But as I am new in Swift without any Obj-C knowledge, I cannot figure out how to do.

And of course I also need to convert the created string back to a NSAttributedString in order to display it later.
Thanks for your help,
Gilbert

Hi @gilbert,
One way is you can serialize the object which will retain the attributes, the other way is to convert the attributed string to a format like Markdown or HTML and save it but you have to also convert it back.

Unless I did not quite understand what you are after,

cheers,

Jayant