Character replace in String from database (Objective-C)
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 descr开发者_开发百科iption]];
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,
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"];
You can use:
- (NSString *)stringByReplacingOccurrencesOfString:(NSString *)target withString:(NSString *)replacement
精彩评论