views:

62

answers:

2

Hi,

I have a UITableView and each row I cliked display a UIViewController containing information store in my database like this:


[self.myViewController.myViewControllerDescription setText:[self.fiche description]];

The information store in the database contains HTML syntaxe ( < BR > ) and I display them in a UITextView (as you know the UITextView will not recognize the < BR > tag),

I wanna know how can I find this character inside my result and replace it with word wrap, I thik its'/n'

Thanks,

A: 

You can use:

 - (NSString *)stringByReplacingOccurrencesOfString:(NSString *)target withString:(NSString *)replacement
ennuikiller
+1  A: 

Given some string, you can find all instances of <br> and replace them with the "newline" character (denoted in C and Objective-C by \n) with the NSString method stringByReplacingOccurrencesOfString:withString:, as such:

NSString *stringWithNewlines = [stringWithBRs stringByReplacingOccurrencesOfString:@"<br>" withString:@"\n"];
Tim
The problem is that the /n is not recognize in the UITextView, it will just write /n, so what do I have to use?
ludo
You need to use \n, NOT /n.
Ben Gottlieb
Yes I know sorry I just made a mistake when I write. And I know why it didn't work too when I write withString:@"\n", I have to write withString:@" \n" I forget to put a space. Thank you~~
ludo