简体   繁体   中英

Xcode6 swift type inference bug?

Any view controller by adding the following code:

The Xcode6 will stop working.

Unable to compile and run.

is a xcode problem?

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. 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). 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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