代码如下:
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), {
var error: NSError?
let responseDictionary: Dictionary<String, AnyObject> = NSJSONSerialization.JSONObjectWithData(data, options: nil, error: &error) as Dictionary
let venuesArray: AnyObject = (responseDictionary as AnyObject).valueForKeyPath("response.venues")
for test: AnyObject in venuesArray {
println(test)
}
});
我得到的错误是:Type 'AnyObject' does not conform to protocol 'Sequence'
有解决方法吗?
答案 0 :(得分:2)
问题在于venuesArray
循环期望数组类型不是单个对象:
在您的代码中:let venuesArray: AnyObject =
//这不是数组,
let venuesArray: AnyObject[] =
//这可能是anyObject的数组
相应地尝试实现目标。