Сообщение об аварийном завершении iOS "неожиданное начало"?
Я нашел несколько отчетов о сбоях с причиной 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;
}
Отчет о сбое выглядит следующим образом:
![enter image description here]()
Ответы
Ответ 1
Просто вызовите свою функцию в фоновом потоке:
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{
// here, call your function
dispatch_async(dispatch_get_main_queue(), ^{
// do updates on main thread
});
});