好的,我们在这里:
NSTextViewNSMutableAttributedString的内容通过使用Rob的代码( Saving custom attributes in NSAttributedString ),我已经取得了一些进展(我正在设法将数据写入磁盘),但我无法恢复它(= NSKeyedUnarchiver返回nil)。
编码:
// where MAS --> NSMutableAttributedString
NSData* stringData = [NSKeyedArchiver archivedDataWithRootObject:MAS];解码:
NSMutableAttributedString* mas = (NSMutableAttributedString*)[NSKeyedUnarchiver unarchiveObjectWithData:dat];有什么想法吗?任何可能的解决办法(即使不是使用NSCoder,我怀疑它适用于RTF.)会受到欢迎的!
发布于 2012-09-10 17:56:37
这是如何被解决的。
NSAttributedString ->
NSData* j = [(NSMutableAttributedString*)MAS RTFDFromRange:NSMakeRange(0,[[MAS string] length])
documentAttributes:nil];NSData -> NSAttributedString
NSMutableAttributedString* mas = [[NSMutableAttributedString alloc] initWithRTFD:dat
documentAttributes:nil];就这么简单。
https://stackoverflow.com/questions/12356134
复制相似问题