I have a expandable table with custom cells that appear or disappear when a visible row is tapped. The cell's data is stored in a plist and declared as a NSMutableArray.
I get an 'ambiguous use of subscript' error in the following code and was hoping somebody else has encountered this and know the fix. I've tried all possible options, to my limited knowledge I must add.
var cellDescriptors: NSMutableArray!
func getCellDescriptorForIndexPath(indexPath: NSIndexPath) -> [String: AnyObject] {
let indexOfVisibleRow = visibleRowsPerSection[indexPath.section][indexPath.row]
let cellDescriptor = cellDescriptors[indexPath.section][indexOfVisibleRow] as! [String: AnyObject]
return cellDescriptor
}
func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
let indexOfTappedRow = visibleRowsPerSection[indexPath.section][indexPath.row]
if cellDescriptors[indexPath.section][indexOfTappedRow]["isExpanded"] as! Bool == true { // Ambiguous use of subscript error
var shouldExpandAndShowSubRows = false
if cellDescriptors[indexPath.section][indexOfTappedRow]["isExpanded"] as! Bool == false { // Ambiguous use of subscript error
// In this case the cell should expand.
shouldExpandAndShowSubRows = true
}
Cor, I'm assuming you resolved this by now but having found a solution, I thought I would bring it to your attention:
func getCellDescriptorForIndexPath(indexPath: NSIndexPath) -> [String: AnyObject] {
let indexOfVisibleRow = visibleRowsPerSection[indexPath.section][indexPath.row]
// HERE IS WHAT YOU WANT:
let cellDescriptor = (cellDescriptors[indexPath.section] as! NSMutableArray)[indexOfVisibleRow] as! [String: AnyObject]
return cellDescriptor
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With