@lvalue NSMutableArray'不能转换为'SequenceType'

时间:2015-07-10 08:12:39

标签: ios swift loops nsmutablearray

我正在试图在Swift中循环NSMutableArray。但是为什么我会在这样的简单情况下得到这个错误:

// note : `responseObject:AnyObject!`

var temp = NSMutableArray(array: responseObject as! [AnyObject])

for a:NSDictionary in temp { // @lvalue NSMutableArray' is not convertible to 'SequenceType'
    // Do some stuff here...
}

1 个答案:

答案 0 :(得分:1)

这应该有效:

var temp = NSMutableArray(array: responseObject as! [AnyObject])

for a in (temp as NSArray as! [NSDictionary]) {
    // 'a' is of type 'NSDictionary'
    // Do some stuff here...
}