Cocoa: How to save NSAttributedString to JSON

前端 未结 3 567
太阳男子
太阳男子 2021-02-10 06:36

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:24

    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).

提交回复
热议问题