wenming
wenming

Reputation: 3

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"
    ]
]

Upvotes: 0

Views: 84

Answers (1)

vacawama
vacawama

Reputation: 154603

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.

Upvotes: 1

Related Questions