数据库中的字符串中的字符替换(Objective-C) [英] Character replace in String from database (Objective-C)
问题描述
我有一个UITableView,我喜欢的每一行都显示一个UIViewController,其中包含数据库中的信息,如下所示:
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]];
数据库中的信息存储包含HTML语法(< BR>),我将它们显示在
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),
UITextView(您知道UITextView无法识别< BR>标记),我想知道如何在结果中找到该字符并替换加上自动换行,我觉得它是'/ n'
谢谢,
推荐答案
给出一些字符串,您可以找到< br>
的所有实例,并将它们替换为换行符(用C和Objective表示)。 -C由 \n
)使用NSString方法 stringByReplacingOccurrencesOfString:withString:
,例如:
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"];
这篇关于数据库中的字符串中的字符替换(Objective-C)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!