Below code is crashing(not always but rarely) despite the fact that it is inside do-catch block.
Fabric crashlytics states that exception is Fatal Exception: NSInternalInconsistencyException and sometimes this EXC_BAD_ACCESS KERN_PROTECTION_FAILURE 0x000000016fccb1f8
do {
return try NSAttributedString(
data: data,
options: [
.documentType: NSAttributedString.DocumentType.html,
.characterEncoding: String.Encoding.utf8.rawValue
],
documentAttributes: nil
)
} catch {
return NSAttributedString()
}
While I read apple docs of NSAttributedString it states that it should be on main thread so I surround it with Dispatch.main.async block but doing this is not setting the styles that are set on NSAttributedString