Saving custom attributes in NSAttributedString

Posted by regulus6633 on Stack Overflow See other posts from Stack Overflow or by regulus6633
Published on 2010-04-13T02:51:27Z Indexed on 2010/04/13 2:52 UTC
Read the original article Hit count: 643

I need to add a custom attribute to the selected text in an NSTextView. So I can do that by getting the attributed string for the selection, adding a custom attribute to it, and then replacing the selection with my new attributed string.

So now I get the text view's attributed string as NSData and write it to a file. Later when I open that file and restore it to the text view my custom attributes are gone! After working out the entire scheme for my custom attribute I find that custom attributes are not saved for you. Look at the IMPORTANT note here: http://developer.apple.com/mac/library/DOCUMENTATION/Cocoa/Conceptual/AttributedStrings/Tasks/RTFAndAttrStrings.html

So I have no idea how to save and restore my documents with this custom attribute. Any help?

© Stack Overflow or respective owner

Related posts about objective-c

Related posts about cocoa