我有一个TableViewController,其中包含使用CoreData的数据输入列表。我也有ViewView与TextView。我已完成添加,保存和删除项目等操作。现在我正在通过在下一个ViewController上将选定的TableViewCell链接到TextView来进行编辑。但是,我在IndexPath'中遇到了错误。不能转换为“IndexPath”#。如何解决这个错误?
答案 0 :(得分:0)
let indexPathForSelectedRow = tableView.indexPathForSelectedRow
let row: Int = (indexPathForSelectedRow?.row)!
print(row);
答案 1 :(得分:0)
func getIndexPathForSelectedCell() -> IndexPath?
{
var indexPath2:IndexPath?
if TABLEVIEW.indexPathsForSelectedItems!.count > 0 {
indexPath2 = TABLEVIEW.indexPathsForSelectedItems![0]
}
return indexPath2
}
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if (segue.identifier == "detailView")
{
print("Segue Clicked. werwerewrere..................................")
if let indexPath2 = getIndexPathForSelectedCell()
{
// here write code for move to next controller.
let YOUR_NEXT_CONTROLLER_OBJECT = segue.destination as! YOUR_NEXT_CONTROLLER_CLASS_NAME
YOUR_NEXT_CONTROLLER_OBJECT.KEY = PASS_DATA_VALUE
}
}
}