3lvis/DATASource

No Example to delete items in table-view

Closed this issue · 2 comments

Hey 3lvis,

can you please share an example to delete and refresh cells in table-view like:

extension MyViewController:DATASourceDelegate {
    func dataSource(_ dataSource: DATASource, tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: IndexPath) {
        
        tableView.beginUpdates()
        
        if editingStyle == .delete {
            tableView.deleteRows(at: [indexPath], with: .automatic)
        }
        
        tableView.endUpdates()
    }
    
    func dataSource(_ dataSource: DATASource, tableView: UITableView, canEditRowAtIndexPath indexPath: IndexPath) -> Bool {
        return true
    }
 
}

Thank you.

Regards
Peter

3lvis commented

Hi Peters!

Added a new example, I hope this is what you were looking for, otherwise let me know. https://github.com/SyncDB/DATASource/blob/master/SwiftDemo/TableViewControllerDeleteCells/TableViewControllerDeleteCells.swift

Have a great day!

awsome :)