Der folgende Code stürzt kontinuierlich auf iOS ab. Bitte helfen Sie mir, die genaue Ursache für diese Fehler herauszufinden.iOS crash @ NSMutableAttributedString
@try { dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{
NSMutableAttributedString *attributedString =[[NSMutableAttributedString alloc]initWithData:[attrString dataUsingEncoding:NSUTF8StringEncoding] options:@{ NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType, NSCharacterEncodingDocumentAttribute:@(NSUTF8StringEncoding) } documentAttributes:nil error:nil];
dispatch_async(dispatch_get_main_queue(), ^{
//Any UI updates
[self.attributedLabel setAttributedText:attributedString];
});
});
}
@catch (NSException *exception) {
DLog(@"Trace exception : %@",exception.description);
}
@finally {
}
Und bekam die folgende Meldung von Xcode Veranstalter:
Anstatt try/catch in Ziel c zu verwenden, sollten Sie einen NSError-Verweis auf den Fehlerparameter angeben und prüfen, ob der Fehler nicht null ist. – Paulw11
Wie funktioniert es mit GCD? – trojanfoe