项目中有一个方法的作用是把 HTML 字符串解析成 AttributedString,升级到 Swift 3 后,下面这段代码会 crash。 var attributedString: NSAttributedString do { try attributedString = NSAttributedString( data: htmlString.data(using: String.Encoding.utf8)!, options: [ NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType, NSCharacterEncodingDocumentAttribute: String.Encoding.utf8 ], documentAttributes: nil)