fs_tigre
fs_tigre

Reputation: 10738

What is the process to Edit/Change data in a row from a UITableView - Swift

Can someone describe the process to edit/change the content from a row in a UITableView?

It looks like there is no enumerator for edit.

From the docs: UITableViewCellEditingStyle

Here is how I delete rows and update table.

func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath) {
    if editingStyle == UITableViewCellEditingStyle.Delete {
        myArray.removeAtIndex(indexPath.row)
        myTableView.deleteRowsAtIndexPaths([indexPath], withRowAnimation: UITableViewRowAnimation.Automatic)
    }
}

Upvotes: 0

Views: 792

Answers (1)

Rajat
Rajat

Reputation: 11127

With the below code you can update any single cell of tableview

let indexPath = NSIndexPath(forRow: path, inSection: section)
tableView.beginUpdates()
self.tableView.reloadRowsAtIndexPaths([indexPath], withRowAnimation: UITableViewRowAnimation.None)
tableView.endUpdates()

Upvotes: 1

Related Questions