【发布时间】:2013-05-03 17:08:10
【问题描述】:
我有 NSString,我需要创建 NSAttributedString。
NSString 类似于:
bvcx b vcxbcvx bcxvbcxv bvx xbc bcvx bxcv bcxv bcxv bcxv bcvx bcvx bcxvbcvx bvc bcvx bxcv{
NSFont = "\"LucidaGrande 24.00 pt. P [] (0x108768a80) fobj=0x108788880, spc=7.59\"";
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 (null), Lists (null), BaseWritingDirection -1, HyphenationFactor 0, TighteningFactor 0.05, HeaderLevel 0";
}
它是 UTF-8 格式的 NSAttributedString。有什么办法可以做到吗?
【问题讨论】:
-
您在寻找
NSAttributedString *attrStr = [[NSAttributedString alloc] initWithString:@"foo"];吗? -
不,我需要格式化的 nsattributestring。谢谢感兴趣。
-
您的
NSString内容从何而来? -
NSString 不是 UTF8。您的字符串似乎是某种文字处理器程序的输出(甚至可能是 NSAttributedString 的
description输出——我从未见过),并且您需要了解该格式来处理它(如果还没有属性字符串)。 Objective-C 中没有“自动”机制来执行该翻译。 -
或者,或者,执行
NSLog(@"The class is %s", object_getClassName(myFunnyString));,然后查看打印的类名。
标签: objective-c cocoa nsstring nsattributedstring