Swift NSIndexPath中的indexPath是什么

Swift NSIndexPath中的indexPath是什么,swift,tableview,nsindexpath,Swift,Tableview,Nsindexpath,我有一箱代码 func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { let cell = UITableViewCell(style: UITableViewCellStyle.Default, reuseIdentifier: "Cell") cell.textLabel?.text = toDoList[ind

我有一箱代码

func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {

    let cell = UITableViewCell(style: UITableViewCellStyle.Default, reuseIdentifier: "Cell")

    cell.textLabel?.text = toDoList[indexPath.row] //will give us the 0th, 1st, 2nd etc..

    return cell
有人能给我解释一下第一行中的“indexPath”是什么吗

访问


他们得到了一个关于indexPath的好文档。

NSIndexPath
NSObject
的一个子类。它表示数组集合树中特定节点的路径

您的问题基于tableView。在表视图中有一组单元格。因此,节点就是您选择的单元


indepath
表示此处树中选定的单元格

indepath
是外部名称为
cellforrowatinexpath
的参数的本地名称

indepath
是在函数体内部定义的(您可以使用它),而函数调用方在命名函数参数时必须使用
cellforrowatinexpath
:让cell=tableView.delegate.tableView(tableView,cellforrowatinexpath:…)

比较:

func sum1(a: Int, b: Int) -> Int {
    return a + b
}

func sum2(a: Int, _ b: Int) -> Int {
    return a + b
}

func sum3(integer a: Int, secondInteger b:Int) -> Int {
    return a + b
}

sum1(1, b: 2)
sum2(1, 2)
sum3(integer: 1, secondInteger: 2)
现在您可以查看有关函数参数名称的Apple文档了: