在 Mac OS X 中,添加了 AppKit,支持以 RTF 格式读取和写入 NSAttributedString。
iOS 中的同等功能吗?我应该自己做吗?
您只想将字符串保存到磁盘吗?我会使用 NSCoding 来实现这一点。
将对象写入文件:
result = [NSKeyedArchiver archiveRootObject:attributedString toFile:archivePath];
从文件中读取对象:
attributedString = [NSKeyedUnarchiver unarchiveObjectWithFile:archivePath];
您可以对任何符合“NSCoding”的对象执行此操作,并且向您自己的类添加对 NSCoding 的支持相当容易。更多信息请访问:
http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/Archiving/Archiving.html%23//apple_ref/doc/uid/10000047-SW1 http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/Archiving/Archiving.html%23//apple_ref/doc/uid/10000047-SW1
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)