NSAttributedString EXC_BAD_ACCESS KERN_INVALID_ADDRESS crash

流过昼夜 提交于 2019-12-01 21:27:29

问题


I am using NSAttributedString in my code. I am getting the below crash sometimes.

Crashed: com.apple.main-thread EXC_BAD_ACCESS KERN_INVALID_ADDRESS 0x00000000114f2841 Raw 0 libobjc.A.dylib
objc_msgSend + 5 15 UIFoundation
-[NSAttributedString(NSAttributedStringUIFoundationAdditions) initWithData:options:documentAttributes:error:] + 116

Can somebody help me out on this?. Thanks in advance.


回答1:


If you working with HTML strings in NSAttributedString it also may crash, as it said in docs:

The HTML importer should not be called from a background thread (that is, the options dictionary includes NSDocumentTypeDocumentAttribute with a value of NSHTMLTextDocumentType). It will try to synchronize with the main thread, fail, and time out. Calling it from the main thread works (but can still time out if the HTML contains references to external resources, which should be avoided at all costs). The HTML import mechanism is meant for implementing something like markdown (that is, text styles, colors, and so on), not for general HTML import.

Anyway you should provide more details for your crash to get correct answer.



来源:https://stackoverflow.com/questions/37915411/nsattributedstring-exc-bad-access-kern-invalid-address-crash

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!