IOS displays the HTML text

In the development, there will inevitably appear HTML text, but need to do the front-end processing, and then show. Only need to write a NSString classification can be as follows:

* / * * H5 tag attribute - * / return escape (NSString*) htmlText NSDictionary* NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType {options = @{}; NSMutableAttributedString* attrs = [[NSMutableAttributedString alloc] initWithData:[self dataUsingEncoding:NSUnicodeStringEncoding] options:options documentAttributes:nil error:nil]; return attrs.string;}

For example, I want to display the following text:

Displays the text of NSString* / / htmlTagText = @ "a book called & ldquo; & rdquo; sword;" to UIlabel self.htmlLabel.text / / = htmlTagText;

Effect is as follows:

IOS displays the HTML text
unwanted results

This is not the result we want. Replace the code with this:

Displays the text of NSString* / / htmlTagText = @ "a book called & ldquo; & rdquo; sword;" htmlTagText = [htmlTagText htmlText] / / parsetext; / / self.htmlLabel.text = htmlTagText to UIlabel;

The results are as follows:

IOS displays the HTML text
perfect

Well Done!

Thank you ~!