Swift 3 - 类型 'Any' 没有下标成员

Swift 3 - Type 'Any' has no subscript members

我将我的项目升级到 Swift 3 并遇到了这个错误:

let cellDescriptor = cellDescriptors[(indexPath as NSIndexPath).section][indexOfVisibleRow] as! [String: AnyObject]

我在这一行遇到错误:

Type 'Any' has no subscript members

我该如何解决这个问题?我不知道该怎么做。我尝试将第一部分转换为 NSDictionary,然后它告诉我类型 IndexPathindexPath 无法转换为 NSIndexPath.

NSIndexPath 已替换为 IndexPath,因此该部分应该变得简单

cellDescriptors[indexPath.section]

对于剩下的问题,您是如何定义 cellDescriptors 的?作为 two-step 流程

执行此操作可能更容易
let firstPart = cellDescriptors[indexPath.section] as! MyCellDescriptor
let cellDescriptor = firstPart[indexOfVisibleRow]