swift 值绑定(以tableView.CellforRow为例)

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
    //元组(section,row)
    switch (indexPath.section,indexPath.row) {
    case (1,0):
        let cell = tableView.dequeueReusableCell(withIdentifier: "tableViewCell4", for: indexPath) as! tableViewCell4
        return cell
    //值绑定(section == 1,row >= 1(row==0在上一个case已经走了)) x = row
    case (1,let x):
        let cell = tableView.dequeueReusableCell(withIdentifier: "tableViewCell5", for: indexPath) as! tableViewCell5
        return cell
    default:
        let cell = tableView.dequeueReusableCell(withIdentifier: "tableViewCell5", for: indexPath) as! tableViewCell5
        return cell
    }
}

你可能感兴趣的:(swift 值绑定(以tableView.CellforRow为例))