开发者

Character replace in String from database (Objective-C)

开发者 https://www.devze.com 2022-12-15 20:17 出处:网络
I have a UITableView and each row I cliked display a UIViewController containing information store in my database like this:

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
0

精彩评论

暂无评论...
验证码 换一张
取 消