我正在通过这appcoda blog并遇到一个函数,我必须得到可见行的索引。我正在学习和实施Swift 3
/Xcode 8
。对于以下功能,我得到No subscript members
错误。'NSFastEnumerator.Element'(又名'Any')没有下标成员
func getIndicesOfVisibleRows() {
visibleRowsPerSection.removeAll()
for currentSectionCells in cellDescriptors {
var visibleRows = [Int]()
for row in 0...((currentSectionCells as! [[String: AnyObject]]).count - 1) {
if currentSectionCells[row]["isVisible"] as! Bool == true { //Get compile time error here
visibleRows.append(row)
}
}
visibleRowsPerSection.append(visibleRows)
}
}
如何获得currentSectionCells
数组,其对象为重点的对象“isVisible
”在这里?
你确定有**两个循环吗? – vadian
@vadian:是的,有两个for循环。请参考链接博客中的功能。 –
我不明白,** Swift **教程仍然建议不相关的集合类型,如'MSMutableArray'和丑陋的老式C风格循环。 Swift中有更好更有效的方法。 – vadian