简体   繁体   English

Xcode6快速类型推断错误?

[英]Xcode6 swift type inference bug?

Any view controller by adding the following code: 通过添加以下代码的任何视图控制器:

The Xcode6 will stop working. Xcode6将停止工作。

Unable to compile and run. 无法编译和运行。

is a xcode problem? 是xcode问题吗?

let popularTableData = [
    [
        "id": 1,
        "title": "xxx"
    ],
    [
        "id": 2,
        "title": "xxx"
    ],
    [
        "id": 3,
        "title": "xxx"
    ],
    [
        "id": 4,
        "title": "xxx"
    ],
    [
        "id": 5,
        "title": "xxx"
    ],
    [
        "id": 6,
        "title": "xxx"
    ],
    [
        "id": 7,
        "title": "xxx"
    ]
]

Yes, it is a bug. 是的,这是一个错误。 The Swift compiler has a problem determining the type of popularTableData in this case. 在这种情况下,Swift编译器在确定popularTableData的类型时popularTableData问题。 Give it some help by explicitly declaring the type: 通过明确声明类型来为其提供帮助:

let popularTableData: [[String: AnyObject]] = [

I placed your code in a Playground, and it eventually worked (after over a minute). 我将您的代码放在一个Playground中,并且最终成功了(一分钟后)。 The compile time seems to increase exponentially with each extra dictionary element added to the array. 随着每个额外的字典元素添加到数组中,编译时间似乎成倍增加。 When you tell the compiler the type, it compiles quickly. 当您告诉编译器类型时,它会快速编译。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM