【问题标题】:HTML string is not Working in MAC CatalystHTML 字符串在 MAC Catalyst 中不起作用
【发布时间】: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
)}'.

【问题讨论】:

    标签: swift macos catalyst


    【解决方案1】:

    我认为这是 Mac Catalyst 的错误。 NSAtributed String 生成的 NSColor 在 Catalyst 中不受支持

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-02-03
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多