iphoneobjective-cthree20ttstyledtextlabel

TTStyledText not displays string which has '<' charcter


I am using TTStyledText to display text on my tableView. I came across a problem where, If my TTStyledText text contains '<' character than my complete text becomes null.

TTStyledText *text = [TTStyledText textFromXHTML:@"3<5" lineBreaks:YES URLs:YES];

[tnc setText:text];

NSLog(@"tnc - %@ & Text is - %@", tnc, tnc.text);

tnc is of type TTStyledTextLabel.

Logs displays the object but text as (null).

Thanks.


Solution

  • Use @"3&#x3C;5" instead of @"3<5"

    Here < is a special entity so you should use html code for < which is &#x3C; or &lt; or &#60; defined here.