Muju Muju - 4 years ago 121
iOS Question

How to add HTML Tags in NSMutableArray in objective c

I am new in iOS and I am facing problem regarding to add HTML content in NSMutableArray in UITableView.

I am using code like this

namearray=[[NSMutableArray alloc]init];
namearray=[responsedict valueForKey:@"News"];

NSMutableArray *trimmedStrings = [NSMutableArray array];
for (NSString *string in namearray) {
NSCharacterSet *doNotWant = [NSCharacterSet characterSetWithCharactersInString:@"<p></p>&amp;#39;"];
NSString *trimmedString = [[string componentsSeparatedByCharactersInSet: doNotWant] componentsJoinedByString: @""];
[trimmedStrings addObject:trimmedString];
}
namearray = trimmedStrings;


But this code remove tag not adding HTML content.I am getting value in array like this
"<p>&quot;I don&#39;t want to live in a lie anymore. When I was 10, my mother in a hotel in Athens, Greece.</p>"
How to solve this issue.
Thanks in Advance!

Answer Source
NSString *aux = @"your string";
 NSAttributedString * attrStr = [[NSAttributedString alloc] initWithData:[aux dataUsingEncoding:NSUnicodeStringEncoding] options:@{ NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType,NSFontAttributeName:font} documentAttributes:nil error:nil];`

set font which you want to set in font attribute

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download