2012-04-26 61 views
0

我有一个UITableview,在tableview中我抓取了一个JSON提要。但有时它会显示htmlcharacters,如“而不是有谁知道我可以如何在xcode中进行转换?Textlabel中的Htmlcharacters

我可以为我的文本标签设置编码吗?

[[cell textLabel] setText:[item objectForKey:@"title" ]]; 

回答

0

当我从Web服务器获取字符串,如果他们正在往任何用户界面,我平时去虱(errr,去百分号转义),通过这个“NSString”的方法:

stringByReplacingPercentEscapesUsingEncoding(为您链接的文档)。

这可以避免URL编码的字符串。

现在,对于像“&#8220”这样的HTML字符,需要额外的NSString类别来完成一些工作。

And other people have already written this category for you. Take a look at the various answers here其中一个应该很好。

相关问题