Replacing linebreaks with use in UIWebView

I retrieve my data from sqlite and try to show it in a UIWebView
I 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 seem to be doing the job. Any ideas?

+3
source share
1 answer

It worked

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

what i did, i escaped a new line. I didn’t just press “enter” while writing the code, but I copied and pasted from the database output in the console.

+9
source

Source: https://habr.com/ru/post/1759049/


All Articles