NSAttributedString EXC_BAD_ACCESS KERN_INVALID_ADDRESS崩溃 [英] NSAttributedString EXC_BAD_ACCESS KERN_INVALID_ADDRESS crash

查看:327
本文介绍了NSAttributedString EXC_BAD_ACCESS KERN_INVALID_ADDRESS崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在代码中使用了NSAttributedString.有时我会遇到下面的崩溃.

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

崩溃:com.apple.main-thread EXC_BAD_ACCESS KERN_INVALID_ADDRESS 0x00000000114f2841 生的 0 libobjc.A.dylib
objc_msg发送+ 5 15 UIFoundation
-[NSAttributedString(NSAttributedStringUIFoundationAdditions)initWithData:options:documentAttributes:error:] + 116

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.

推荐答案

如果您在NSAttributedString中使用HTML字符串,也可能会崩溃,如

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

不应从后台线程调用HTML导入器( 是,选项字典包含NSDocumentTypeDocumentAttribute 的值为NSHTMLTextDocumentType).它将尝试同步 与主线程,失败,并超时.从主叫 线程有效(但如果HTML包含引用,仍可能超时 外部资源,应不惜一切代价避免).的HTML 导入机制旨在实现诸如markdown之类的东西 (即文本样式,颜色等),而不适用于常规HTML 导入.

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.

这篇关于NSAttributedString EXC_BAD_ACCESS KERN_INVALID_ADDRESS崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆