ios - 如何解决 "Type of expression in ambiguous without more context"?

标签 ios swift compiler-errors

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

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

最佳答案

要求[String : AnyObject]attributedOptions 参数要求的格式

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/

相关文章:

oracle - PL/SQL过程错误

iphone - ios safari 不会在 svg 文件中显示 font-face 嵌入字体。任何修复?

ios - 防止 UITableViewCells 在平移时突出显示

ios - PresentViewController 来自 AppDelegate handleActionWithIdentifier

ios - SWIFT 中的 audioPlayerDidFinishPlaying 函数

ios - 模拟器和设备之间的 Storyboard布局不同

c++ - 使用桌面 OpenGL 构建 Qt 时出错

python - 无法运行Python脚本

ios - Objective-C 中的所有对象基本上都是指针吗?

ios - 从 parse.com 中提取数据,但它根本没有显示在 ios 的 UITableView 中(swift)