Cocoa: How to save NSAttributedString to JSON

前端 未结 3 954
梦毁少年i
梦毁少年i 2021-02-10 06:44

I have a NSAttributedString object as a property of a custom object. I need to save this custom object to the disk in JSON format. Later I need to

3条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-02-10 07:15

    You could try starting with RTFFromRange:

    From the documentation: For information about the OS X methods supporting RTF, ..., see NSAttributedString Application Kit Additions Reference.

    RTF should be self contained. RTFFromRange: returns NSData; I would think its probably character data in some encoding so should be easy to convert to NSString.

    (Sorry, just read that method is MacOS X only).

提交回复
热议问题