解決Larme:如何rtf的字符串解析目標C
**[[NSAttributedString alloc] initWithData:[str_rtf dataUsingEncoding:NSUTF8StringEncoding] options:@{NSDocumentTypeDocumentAttribute: NSRTFTextDocumentType} documentAttributes:nil error:&error]; [yourTextView setAttributedText: attrStr];**
我使用的WebService,並得到RFT字符串格式。但我不能在UITextView rtf字符串中使用。
RTF字符串轉換或解析是可能的嗎?
NSString *str_rtf [email protected]"{\rtf1\ansi\ansicpg1252\cocoartf1038\cocoasubrtf250
{\fonttbl\f0\fnil\fcharset0 LucidaGrande;\f1\fnil\fcharset0 Monaco;}
{\colortbl;\red255\green255\blue255;}
\deftab720
\pard\pardeftab720\sl264\slmult1\sb260\ql\qnatural
\f0\fs26 \cf0 You will need to relaunch Xcode after this install to make it load the plugin.\
This package installs both version 2.x and 1.x of DMD, but you can customize the install to get only one or the other.\
With the two versions installed, D for Xcode uses DMD\'a02.x by default. You can override this setting in your Xcode project on a per-target basis by creating a custom build rule in each target\'92s settings. Alternatively, you can change the system default by typing this command from the terminal:\
\pard\pardeftab720\li560\sl264\slmult1\sb260\ql\qnatural
\f1\fs22 \cf0 sudo setdmd 1
\f0\fs26 \
\pard\pardeftab720\sl264\slmult1\sb260\ql\qnatural
\cf0 This will change the symlinks to make the
\f1\fs22 dmd
\f0\fs26 command point to
\f1\fs22 dmd1
\f0\fs26 .}"
最好的問候。
與NSAttributedString嘗試:https://developer.apple.com/reference/foundation/nsattributedstring/1524613-initwithdata?language=objc – Larme
您好我知道NSAttributedString,但我沒有一個樣品:( – Jealian
Larme謝謝^ ^,非常非常感謝你 – Jealian