我有一个UITableview,在tableview中我正在抓取一个JSON提要。但有时它会显示像“
这样的html字符,而不是“
有没有人知道如何在xcode中转换它?
我可以为我的textlabel设置编码吗?
[[cell textLabel] setText:[item objectForKey:@"title" ]];
答案 0 :(得分:0)
当我从Web服务器获取字符串并且它们的目的地是任何用户界面时,我通常通过这种“NSString
”方法取消(错误,去除百分比 - 转义它们):
stringByReplacingPercentEscapesUsingEncoding
(与您相关的文档)。
这消除了URL编码的字符串。
现在,对于像““
”这样的HTML字符,需要额外的NSString类别来完成一些工作。
And other people have already written this category for you. Take a look at the various answers here其中一个应该运作良好。