我使用下面的代码来解码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代码?
我不想使用异步OR GCD,因为我在存储数据库中的记录时使用此代码。
所以请提出一些替代方案。提前谢谢。
答案 0 :(得分:0)
如果您在数据库中存储记录,那么您可以使用后台队列和Loader或HUD。因为您要解码的数据太多会花费更多时间。所以我认为请在后台进行操作