好的,我们在这里:
- 我有一个
NSTextView
- 我得到它的
NSMutableAttributedString
内容 - 我无法将其读/写到 plist
通过使用 Rob 的代码(在 NSAttributedString 中保存自定义属性),我取得了一些进展(我正在设法将数据写入磁盘),但我无法恢复它(=NSKeyedUnarchiver
返回nil
)。
编码:
// where MAS --> NSMutableAttributedString
NSData* stringData = [NSKeyedArchiver archivedDataWithRootObject:MAS];
解码:
NSMutableAttributedString* mas = (NSMutableAttributedString*)[NSKeyedUnarchiver unarchiveObjectWithData:dat];
有任何想法吗?任何可能的解决方法(即使不使用NSCoder
,我怀疑它是否适用于 RTF...)都将受到欢迎!