Swipe delete in UIViewController with UITableView and UITableViewDiffableDataSource
I have a UIViewController
with a UICollectionView
and a UITableView
. Both views use UICollectionViewDiffableDataSource
and UITableViewDiffableDataSource
respectively.
In the table, I am trying to set up swipe functionality for the delete action. It was a very simple task with a regular data source, but I can't get it to work with the diffable one.
I tried creating a custom class for UITableViewDiffableDataSource
, but I wasn't even able to compile the code with my attempts to access the property from the controller. (I needed to access the property storing the model to delete not only the row, but also the data.) Using UITableViewDelegate
with a tableView(leadingSwipeActionsConfigurationForRowAt:)
did compile, and I could swipe, but the app cra开发者_JS百科shed with an error: UITableView must be updated via the UITableViewDiffableDataSource APIs when acting as the UITableView's dataSource.
How do I do it? Is there a best practice for a job like this?
精彩评论