Adhamox
Adhamox

Reputation: 397

replacing linebreaks with <br> to use in UIWebView

I am pulling my data from sqlite and trying to show it in a UIWebView
I have tried

HTMLData = [container stringByReplacingOccurrencesOfString:@"\n" withString:@"<br />"];  

HTMLData = [HTMLData stringByReplacingOccurrencesOfString:@"\r" withString:@"<br />"];  
HTMLData = [HTMLData stringByReplacingOccurrencesOfString:@"\r\n"   withString:@"<br />"];  

[refweb loadHTMLString:HTMLData baseURL:nil];

but none of them seems to be doing the job. Any ideas?

Upvotes: 3

Views: 2372

Answers (1)

Adhamox
Adhamox

Reputation: 397

This worked

HTMLData = [container stringByReplacingOccurrencesOfString:@"\n" withString:@"<br/>"];  

what I did is I escaped the new line. I didn't just click "enter" while writing the code, but I copied and pasted from the database output in the console.

Upvotes: 9

Related Questions