ios - NSAttributedString - 线程 1:在 iOS 14 上设置属性文本时的 EXC_BREAKPOINT(代码 = EXC_I386_BPT,子代码 = 0x0) -
问题描述
我有一些奇怪的问题。在我的 Macbook M1 上,当我构建我的项目时,everythink 在物理 iPhone XS 14.4 和 8 14.0.1 上运行良好,也在 iOS 14+ 的模拟器上运行良好。但是,当我使用比 14.0 更旧的 iOS 运行任何模拟器时,我的应用程序在设置属性文本时崩溃。这是我的代码:
guard let input = input else { return nil }
guard let data = input.data(using: String.Encoding.unicode, allowLossyConversion: true) else { return nil }
if let string = try? NSAttributedString(data: data, options: [NSAttributedString.DocumentReadingOptionKey.documentType : NSAttributedString.DocumentType.html], documentAttributes: nil).string
{
//Set color and font
let myAttribute = [ NSAttributedString.Key.foregroundColor: UIColor.white , NSAttributedString.Key.font: UIFont.systemFont(ofSize: 17.0) ]
let myAttrString = NSAttributedString(string: string, attributes: myAttribute)
return myAttrString
}
return nil
}
崩溃在这一行:
if let string = try? NSAttributedString(data: data, options: [NSAttributedString.DocumentReadingOptionKey.documentType : NSAttributedString.DocumentType.html], documentAttributes: nil).string
对于NSAttributedString ,我收到错误Thread 1: EXC_BREAKPOINT (code=EXC_I386_BPT, subcode=0x0) 我尝试在 Macbook Intel 上运行我的应用程序,并且在 iOS 14.0 之前的模拟器上一切正常。所以这对我来说很奇怪。我是否应该将应用程序扔到 App Store 上,因为故障仅在于模拟器,或者用户可能有问题?我尝试了互联网上的各种解决方案,我更改了 NSAttributedString 修改,但应用程序总是在同一个地方崩溃。
解决方案
推荐阅读
- guice - 如何绑定动态@Named 绑定
- abap - 形参个数大于实参个数
- javascript - 在角度项目中的数组上设置间隔
- python - 在 localhost 打开但永远保持空白的地方使用 vpython 时出现问题
- scala - Scala 跨项目中的资源
- django - 如何在 django 查询中将表单中的日期与 db 中的日期进行比较?
- django - 在具有嵌套资源的 Tastypie 中,对于给定的 url,获取视图函数名称的最佳方法是什么?
- php - Yii:尽管安装了 memcache/memcached,CMemCache 仍需要加载 PHP memcache 扩展
- python - Python pkg_resources 找不到模块
- postgresql - INSERT 到只有一个串行列的表实际上并没有插入任何东西