ios - "Expression was too complex to be solved in reasonable time"在 swift 3 中向字典添加数据时,在 swift 2.3 中工作正常

标签 ios swift3 xcode8

let parameters : [String : AnyObject] = [
    "address" :      txtAddress.text ?? "",
    "person_name" :  txtAuthorName.text ?? "",
    "person_image" : imgUrl ?? "", 
    "book_title" :   txtBookTitle.text ?? "", 
    "dedicated_to" : txtDedicatedTo.text ?? "" , 
    "person_about" : txtAboutTheAuthor.text ?? "",
    "is_published" : false,
    "recipes" : recipeArr  ?? ""]

这是向字典添加数据的代码。在 Swift2.3 上运行良好。

Swift 3 编译器表示将表达式分解为子表达式。

请提出一个合适的解决方案。

最佳答案

以下面的方式打破它对我来说效果很好

var dictionary =  [String: Any]()
   dictionary["key1"] = value1
   dictionary["key2"] = value2
   //...

关于ios - "Expression was too complex to be solved in reasonable time"在 swift 3 中向字典添加数据时,在 swift 2.3 中工作正常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40526914/

相关文章:

ios - Application Loader 无法读取 Assets.car

ios - UITableView 在滚动时崩溃(内存警告)

swift - 如何提取 swift 3 字典的子集

swift - CK订阅错误iOS10

swift - Xcode 8 故障选项卡栏 View Controller 。 (主从)

iOS swift 3.0本地JSON解析崩溃

swift - 不止一次使用 swift 3 migrator

iphone - 如何在 UITableView 中显示最近添加的部分?

ios - 自定义 UITableviewCell 放弃内存问题

javascript - HTML5 地理定位精度 Android 与 iO 有很大不同