新手问题 xcode6 的 bug?

twm · December 09, 2014 · Last by twm replied at December 09, 2014 · 1829 hits

以下常量,加入一个 ViewController 后,无法 run,一直无限 indexing,cpu 高到 90% 以上

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"
        ],
        [
            "id": 8,
            "title": "xxx"
        ],
        [
            "id": 9,
            "title": "xxx"
        ],
        [
            "id": 10,
            "title": "xxx"
        ]
    ]

Playground 也有这个问题,我把你的数据删到只剩 id: 1 的然后再逐个加回去,发现到了 id: 6 那里就没响应了,Swift 的 bug 可能性比较大

#1 楼 @PrideChung 嗯,比较郁闷。

找到问题了,应该是自动类型推断的时候占用了大量资源,直接显式声明数组的数据类型就好了

let popularTableData: [Dictionary<String, NSObject>] = [ ...

#3 楼 @PrideChung 我擦,果然是类型推断问题,看来不能总依靠类型推断。谢谢你。

You need to Sign in before reply, if you don't have an account, please Sign up first.