1
我使用下面的代码来解码HTML代码:如何解码iOS中的HTML代码?
-(NSString *)decodeString:(NSString *)str
{
// To Remove the HTML code to Nsstring
NSData *stringData = [str dataUsingEncoding:NSUTF8StringEncoding];
NSDictionary *options = @{NSDocumentTypeDocumentAttribute:NSHTMLTextDocumentType}; NSAttributedString *decodedString;
decodedString = [[NSAttributedString alloc] initWithData:stringData options:options documentAttributes:NULL error:NULL];
return decodedString.string;
}
此代码需要很长的时间字符串解码。那么是否有其他解码HTML代码的方法?
我不想使用异步或GCD,因为我在数据库中记录数据时使用了这段代码。
所以请建议一些替代方案。提前致谢。
这些类别不错 –
感谢您的快速回复...。我已经在我的代码中实现了上述解决方案......但是,解码HTML代码需要相同时间......是否有其他解决方案能够以更快的速度解码HTML? –
如果你在数据库中存储记录,那么你可以使用后台队列和Loader或HUD。因为尽可能多的数据,你将解码它将需要更多的时间。所以在我看来,请在背景 –