0

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,

ludo
  • 1,479
  • 5
  • 25
  • 50

2 Answers2

1

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
  • 59,527
  • 19
  • 156
  • 165
  • 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 Jan 11 '10 at 01:18
  • 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 Jan 11 '10 at 01:27
0

You can use:

 - (NSString *)stringByReplacingOccurrencesOfString:(NSString *)target withString:(NSString *)replacement
ennuikiller
  • 46,381
  • 14
  • 112
  • 137