如何在没有更多上下文的情况下解决"模糊的表达类型"?

Dir*_*der 2 compiler-errors ios swift

let attributedString  =  NSAttributedString(data: encodedData, options: attributedOptions, documentAttributes: nil, error: nil)!
Run Code Online (Sandbox Code Playgroud)

编译器错误:"没有更多上下文的模糊表达类型"如何解决?

Anb*_*hik 5

[String : AnyObject]attributionOptions参数所需的格式

do {
        let encodedData = yourEncodedString.dataUsingEncoding(NSUTF8StringEncoding)!
        let attributedOptions : [String: AnyObject] = [
            NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType,
            NSCharacterEncodingDocumentAttribute: NSUTF8StringEncoding
        ]
        let attributedString = try NSAttributedString(data: encodedData, options: attributedOptions, documentAttributes: nil)
       // self.init(attributedString.string)
    } catch {
        fatalError("Unhandled error: \(error)")
    }
Run Code Online (Sandbox Code Playgroud)