iosuitableviewswift

Get indexPath of "next" UITableViewCell


I have some code when tapping on a cell of a table view. Under certain circumstances I want to call the function tableView(_, didSelectRowAtIndexPath) recursively for the next cell. That means that when I selected row 5, I want to select row 6, etc.

How can I get the indexPath of the next cell based on another row?


Solution

  •      override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
    
        let nextIndexPath=NSIndexPath(forRow: indexPath.row + 1, inSection: indexPath.section);
    
        // You should be sure than this NSIndexPath exist, and ...make what you want
    
    }