![ios – Swift-3错误:’ – [_ SwiftValue unsignedIntegerValue]:无法识别的选择器,第1张 ios – Swift-3错误:’ – [_ SwiftValue unsignedIntegerValue]:无法识别的选择器,第1张](/aiimages/ios+%E2%80%93+Swift-3%E9%94%99%E8%AF%AF%EF%BC%9A%E2%80%99+%E2%80%93+%5B_+SwiftValue+unsignedIntegerValue%5D%EF%BC%9A%E6%97%A0%E6%B3%95%E8%AF%86%E5%88%AB%E7%9A%84%E9%80%89%E6%8B%A9%E5%99%A8.png)
func stringByConvertingHTML() -> String { let newString = replacingOccurrences(of: "\n",with: "<br>") if let encodedData = newString.data(using: String.EnCoding.utf8) { let attributedOptions : [String: AnyObject] = [ NSdocumentTypedocumentAttribute: NSHTMLTextdocumentType as AnyObject,NSCharacterEnCodingdocumentAttribute: String.EnCoding.utf8 as AnyObject ] do { let attributedString = try NSAttributedString(data: encodedData,options: attributedOptions,documentAttributes: nil) //Crash here return attributedString.string } catch { return self } } return self} 但是在迅速的3中,它崩溃了
*** Terminating app due to uncaught exception
‘NSinvalidargumentexception’,reason: ‘-[_SwiftValue
unsignedIntegerValue]: unrecognized selector sent to instance
0x6080002565f0’
有人请建议我需要做什么?
解决方法 我遇到了同样的问题:let attributedOptions : [String: AnyObject] = [ NSdocumentTypedocumentAttribute: NSHTMLTextdocumentType as AnyObject,NSCharacterEnCodingdocumentAttribute: String.EnCoding.utf8 as AnyObject ]
这里的String.EnCoding.utf8类型检查失败.使用NSNumber(值:String.EnCoding.utf8.rawValue)
总结以上是内存溢出为你收集整理的ios – Swift-3错误:’ – [_ SwiftValue unsignedIntegerValue]:无法识别的选择器全部内容,希望文章能够帮你解决ios – Swift-3错误:’ – [_ SwiftValue unsignedIntegerValue]:无法识别的选择器所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)