Swift 不出意外的又坑人了。
今天遇到了一个 Swift 无限卡在 Compiling / Indexing 的问题,这个问题导致的原因最终定位到一个关于类型推断的问题
例如下面这段代码就会导致卡在 Compiling / Indexing
var data = [ [ "price": 1, "name": "a" ],
[ "price": 1, "name": "a" ],
[ "price": 1, "name": "a" ],
[ "price": 1, "name": "a" ],
[ "price": 1, "name": "a" ],
[ "price": 1, "name": "a" ],
[ "price": 1, "name": "a" ],
[ "price": 1, "name": "a" ],
]
所以你帮 Swift 做一下推断即可
var data: [[String: AnyObject]] = [ [ "price": 1, "name": "a" ],
[ "price": 1, "name": "a" ],
[ "price": 1, "name": "a" ],
[ "price": 1, "name": "a" ],
[ "price": 1, "name": "a" ],
[ "price": 1, "name": "a" ],
[ "price": 1, "name": "a" ],
[ "price": 1, "name": "a" ],
]