我有一個可擴展的表格,其中包含自定義單元格,當點擊一個可見行時出現或消失。單元格的數據存儲在plist中並聲明爲NSMutableArray。模糊使用下標
我在下面的代碼中得到'模糊使用下標'的錯誤,並希望其他人遇到這種情況並知道修正。 我已經嘗試了所有可能的選擇,對於我必須添加的有限知識。
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
}
謝謝你的廣泛解釋約書亞。我理解這個問題,但不知道如何解決。我的數組/字典存儲在一個plist中,並描述了每個單元格的屬性,如isExpandable,isExpanded,isVisible,Value,Title等。爲了將此移動到'純粹'Swift,您可以給一些指導/建議以使用特定類型? –