let attributedString  =  NSAttributedString(data: encodedData, options: attributedOptions, documentAttributes: nil, error: nil)!

编译器错误:“在没有更多上下文的情况下表达式类型不明确”
怎么解决呢?

最佳答案

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

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)")
    }

关于ios - 如何解决 “Type of expression in ambiguous without more context”?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/37087914/

10-09 09:14