
extension String {var HTMLToAttributedString: NSAttributedString? { guard let data = data(using: .utf8) else { return nil } do { return try NSAttributedString(data: data,options: [NSdocumentTypedocumentAttribute: NSHTMLTextdocumentType,NSCharacterEnCodingdocumentAttribute: String.EnCoding.utf8.rawValue],documentAttributes: nil) } catch let error as NSError { print(error.localizedDescription) return nil }}var HTML2String: String { return HTMLToAttributedString?.string ?? ""} 我收到以下3个相同的错误
Use of unresolved IDentifIEr ‘NSdocumentTypedocumentAttribute’
Use of unresolved IDentifIEr ‘NSHTMLTextdocumentType’
Use of unresolved IDentifIEr ‘NSCharacterEnCodingdocumentAttribute’
我假设我犯了一个错误的语法导致3相同的错误但我无法看到扩展需要什么?
谢谢
NSdocumentTypedocumentAttribute,NSCharacterEnCodingdocumentAttribute,NSHTMLTextdocumentType和文档属性词典的其他键和值
定义于
AppKit框架(macOS)或UIKit框架(iOS):
#if os(macOS) import AppKit#elseif os(iOS) import UIKit#endif总结
以上是内存溢出为你收集整理的swift – 在扩展文件中使用未解析的标识符错误?全部内容,希望文章能够帮你解决swift – 在扩展文件中使用未解析的标识符错误?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)