我正在使用此代码剪切
- 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) // Get crash on this line
- } catch let error {
- print(error.localizedDescription)
- return NSAttributedString()
- }
- }
- var htmlToString: String {
- return htmlToAttributedString?.string ?? ""
- }
在UITableViewCell中显示HTML文本
- cell.textViewMessage.attributedText = msg.htmlToAttributedString
第一次启动没有崩溃,但在那之后,当我运行代码时崩溃并且之后没有工作.
Thread 1: EXC_BAD_ACCESS (code=1,address=0x10)
#Edit HTML要在单元格中显示的字符串
- <p>Here\'s a short video tour. Press play to start.</p><br><iframe class=\"ql-video\" frameborder=\"0\" allowfullscreen=\"true\" src=\"https://www.youtube.com\"></iframe><br>