I used sqlite3 blob type to save NSAttributedString content, query table return NSData type and use below code to convert it to NSAttributedString :
let attributeStr = try? NSAttributedString.init(data: data as Data, options: [:], documentAttributes: nil)
textView.attributedText = attributeStr
But the UITextView show this, how to do about this, thanks a lot.
sorry, the image not show.
just describe :
I build a rich text demo with UITextView, get NSAttributedString and save it in db, then query table to get it and show, I edited "Tttt\nRruuoo" on the page, but the UITextView show below: (it's not in console)
T{
NSColor = "UIExtendedGrayColorSpace 0 1";
NSFont = " font-family: \".SFUI-Regular\"; font-weight: normal; font-style: normal; font-size: 22.00pt";
NSOriginalFont = " font-family: \"Helvetica\"; font-weight: normal; font-style: normal; font-size: 12.00pt";
NSParagraphStyle = "Alignment 4, 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 (\n), Lists (\n), BaseWritingDirection 0, HyphenationFactor 0, TighteningForTruncation NO, HeaderLevel 0 LineBreakStrategy 0";
}ttt{
NSColor = "UIExtendedGrayColorSpace 0 1";
NSFont = " font-family: \".SFUI-Regular\"; font-weight: normal; font-style: normal; font-size: 22.00pt";
NSParagraphStyle = "Alignment 4, 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 (\n), Lists (\n), BaseWritingDirection 0, HyphenationFactor 0, TighteningForTruncation NO, HeaderLevel 0 LineBreakStrategy 0";
}
\
{
NSColor = "UIExtendedGrayColorSpace 0 1";
NSFont = " font-family: \".SFUI-Regular\"; font-weight: normal; font-style: normal; font-size: 14.00pt";
NSParagraphStyle = "Alignment 4, 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 (\n), Lists (\n), BaseWritingDirection 0, HyphenationFactor 0, TighteningForTruncation NO, HeaderLevel 0 LineBreakStrategy 0";
}{
NSFont = " font-family: \".SFUI-Regular\"; font-weight: normal; font-style: normal; font-size: 12.00pt";
}