【发布时间】:2018-04-03 12:45:12
【问题描述】:
我发现了几个崩溃报告,原因是 unexpected start state。我的代码如下所示:
NSRange range = [content rangeOfString:@"<html>"];
if (range.location != NSNotFound) {
NSString *htmlStr = [content substringFromIndex:range.location];
NSAttributedString *attStr = [[NSAttributedString alloc] initWithData:[htmlStr dataUsingEncoding:NSUnicodeStringEncoding] options:@{NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType} documentAttributes:nil error:nil];
return attStr.string;
}
崩溃报告如下所示:
【问题讨论】:
-
看起来您正在加载的数据无效或损坏,或者无法解析。对带有错误处理程序的文档加载器的 try/catch 怎么样?
-
非常感谢。我会试试看它是否起作用
-
我也遇到了类似的问题,请问哪里可以解决?
-
您的 html 有效吗?你是在主线程上调用这段代码吗?
-
这里也一样。任何更新?我无法重现它。
标签: ios crash nsmutableattributedstring nsexception