簡體   English   中英

Xcode6快速類型推斷錯誤?

[英]Xcode6 swift type inference bug?

通過添加以下代碼的任何視圖控制器:

Xcode6將停止工作。

無法編譯和運行。

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

是的,這是一個錯誤。 在這種情況下,Swift編譯器在確定popularTableData的類型時popularTableData問題。 通過明確聲明類型來為其提供幫助:

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

我將您的代碼放在一個Playground中,並且最終成功了(一分鍾后)。 隨着每個額外的字典元素添加到數組中,編譯時間似乎成倍增加。 當您告訴編譯器類型時,它會快速編譯。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM