I want to send the attributedString to the server along with all attribute information and then receive this on another device and display the attributedString in UITextView again. I have created a Transformable attribute in CoreData with NSAttributedString as custom class. i get the UITextView attributedString and save it in CoreData and later on retrieve it and display back on UITextView. This all works fine, however my use case requires me to send the formatted text along with all attributes information to server using REST API. I tried following solutions but none of them worked:
- Convert NSAttributedStringto String (Problem: it removes the formatting information)
- serialise NSAttributedStringobject usingNSKeyedArchiver.archivedDataand then send the resultant Data to server (Problem: I get error in POST method)
- serialise NSAttributedStringand convert the resultant Data to string usingtestString.data(using: String.Encoding.utf8)(Problem: When i try to convert this string back to Data i get error)
Can anybody guide me in this, if i am approaching this problem the right way or not? I am open to upgrading to latest Swift version if there is any new feature which i can use to solve this problem. Any kind of help is appreciated.
Thank you
Affan
 
    