【发布时间】:2020-10-28 22:08:36
【问题描述】:
HTML 属性字符串在 Mac Catalyst 中不工作,但在 iPhone 和 iPad 上工作正常。 HTML字符串代码如下。
var htmlToAttributedString: NSAttributedString? {
guard let data = data(using: .utf8) else { return NSAttributedString() }
do {
return try NSAttributedString(data: data, options: [.documentType: NSAttributedString.DocumentType.html, .characterEncoding:String.Encoding.utf8.rawValue], documentAttributes: nil)
} catch {
return NSAttributedString()
}
}
Mac Catalyst 中的错误是
连接到名为 com.apple.textkit.nsattributedstringagent 的 pid 17352 上的服务:在对消息“renderHTML:options:withReply:”的回复进行解码时捕获异常,丢弃传入消息并调用失败块。
忽略的异常:解码参数 1(调用的#2)时出现异常:
<NSInvocation: 0x600001802d80>
return value: {v} void
target: {@?} 0x0 (block)
argument 1: {@} 0x7fff85206780
argument 2: {@} 0x0
argument 3: {@} 0x0
Exception: value for key 'NS.objects' was of unexpected class 'NSColor'. Allowed classes are '{(
NSNull,
UIColor,
NSArray
)}'.
【问题讨论】: