3lvis / DATASource

Core Data's NSFetchedResultsController wrapper for UITableView and UICollectionView
Other
106 stars 27 forks source link

No Example to delete items in table-view #101

Closed petkrein closed 7 years ago

petkrein commented 7 years ago

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 7 years ago

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!

petkrein commented 7 years ago

awsome :)