我想保存UITextview文本的attributedString。我试图将其转换为字符串并保存。但是,当我回来设置text的attributedString时,它不起作用。
这是我如何转换为字符串:
这是我如何转换为字符串:
var a = String(stringInterpolationSegment: text.attributedText)
Data.setValue(a, forKey: "font")
Data.managedObjectContext?.save(nil)
这是我返回设置的方法:
text.attributedText = NSAttributedString(string: size)
但是我的TextView只显示了AttributedSting。
{
NSFont = "<UICTFont: 0x7fa9fa82aec0> font-family: \"Helvetica Neue\"; font-weight: normal; font-style: normal; font-size: 18.00pt";
NSParagraphStyle = "Alignment 0, LineSpacing 0, ParagraphSpacing 0, ParagraphSpacingBefore 0, HeadIndent 0, TailIndent 0, FirstLineHeadIndent 0, LineHeight 0/0, LineHeightMultiple 0, LineBreakMode 0, Tabs (\n 28L,\n 56L,\n 84L,\n 112L,\n 140L,\n 168L,\n 196L,\n 224L,\n 252L,\n 280L,\n 308L,\n 336L\n), DefaultTabInterval 0, Blocks (null), Lists (null), BaseWritingDirection -1, HyphenationFactor 0, TighteningFactor 0, HeaderLevel 0";
}
很抱歉我不能发布图片。我使用Swift来完成这个操作。
我的问题是:我该怎么做?还有其他方法可以保存attributedText吗?