I have an ios application which fetch a piece of text from server and display it in a TTTAttributedLabel. The text displayed is stripped from a HTML.
E.g.
Original HTML
<p>
Hello <a href="http://www.google.com">World!</a>
</p>
Text display in TTTAttributedLabel
Hello World!
However, I would like the word "World" be clickable as in HTML. I know that TTTAttributedLabel can be used like
TTTAttributedLabel *tttLabel = <# create the label here #>;
NSString *labelText = @"Hello World!";
tttLabel.text = labelText;
NSRange r = [labelText rangeOfString:@"World"];
[tttLabel addLinkToURL:[NSURL URLWithString:@"http://www.google.com"] withRange:r];
But if the word "World" appears more than once in the text, the above code will be wrong.
Can any one suggest a better method to handle this case? Thanks