У меня есть некоторые значения индекса, которые будут меняться каждый раз.Так что в моем VC:
lazy var List: [[String: Any]]? = FetchInfoUtil.sharedInstance.List
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "MainTableViewCell", for: indexPath) as! MainTableViewCell
print(indexPath.row)
switch CurrentIndexVal {
case 1:
cell.Info = List?[0];
case 2:
cell.Info = List?[1];
case 3:
cell.Info = List?[2];
case 4:
cell.Info = List?[3];
case 5:
cell.Info = List?[4];
case 6:
cell.Info = List?[5];
default:
break;
}
if let gList = cell.Info?["list"] as? [[String: Any]] {
SelectedSkill = gList
let gInfo = gList[indexPath.item]
cell.Name.text = gInfo["title"] as? String ?? "NA"
}
return cell
}
и вот проблемы:
func tableView(_ tableView: UITableView, section: Int) -> Int {
let indexPath = IndexPath.init(row: 0, section: 0)
let cell = tableView.cellForRow(at: indexPath) as? MainTableViewCell
guard let gList = cell?.Info?["list"] as? [[String: Any]] else {
return 0
}
return gList.count;
}
Здесь я получаю сбой каждый раз: let cell = tableView.cellForRow(at: indexPath) as? MainTableViewCell
Если мне нужно пройтимои currentIndexVal
в строке или что я здесь делаю. Любая помощь будет полезна для меня здесь.