1

I am getting nested json data from webservices then displaying in UILabel inside a UITableView's Cell. The problem is that data comes in html entity that is like

"Headline Description" = "ephox,パーカーで働くことは、単なる仕事ではam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation \t\t\t\tullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum \t\t\t\tiriure dolor in hendrerit in vulputate velit esse molestie consequat

"Headline Description" = "ephox,&#12497&#12540&#12459t (here is the actual html entity removing semicolon ; because browser converts it automatically in char as above you see in headline desciption)

I need my uilabel to convert like above , UIWebview coverting it but not uilabel,

could anyone please suggest me the way to covert html entity to char like above in bold.

thanks you so much in advance

Pandey_Laxman
  • 3,889
  • 2
  • 21
  • 39
  • check this link http://stackoverflow.com/questions/2606134/iphone-xcode-how-to-convert-nsstring-html-markup-to-plain-text-nsstring – Darshan Kunjadiya Jun 24 '14 at 12:09
  • possible duplicate of [Converting HTML text into plain text using Objective-C](http://stackoverflow.com/questions/19226634/converting-html-text-into-plain-text-using-objective-c) – StrawHara Jun 24 '14 at 12:10
  • There is no possible duplicate of this question you know I want to convert html entity those starts with .. etc as Android TextView converting itself using UTF8 Encoding – Pandey_Laxman Jun 24 '14 at 12:33
  • this url might make sense about html entity http://dev.networkerror.org/utf8/?start=33308&end=33535&cols=4&search=&show_uni_int=on&show_uni_hex=on&show_html_ent=on&show_raw_hex=on&show_raw_bin=on – Pandey_Laxman Jun 24 '14 at 12:34

1 Answers1

1

Finally I found the answer myself posting it here so that someone can get help from here in future.

if (iOS7Version)
        {
            NSData *stringData = [str dataUsingEncoding:NSUTF8StringEncoding];

        NSDictionary *options = @{NSDocumentTypeDocumentAttribute:NSHTMLTextDocumentType};
        NSAttributedString *decodedString;
        decodedString = [[NSAttributedString alloc] initWithData:stringData
                                                         options:options
                                              documentAttributes:NULL
                                                           error:NULL];
        lbl.text=decodedString.string;
    }
    else
        lbl.text=str;
Pandey_Laxman
  • 3,889
  • 2
  • 21
  • 39