I have a UITableViewController with a model property declared in it. When migrating from UITableViewDataSource protocol conformance to a subclass of UITableViewDiffableDataSource outside of the table view controller, the model is no longer accessible in the data source.

What would be a recommended approach to sharing a data model between the two, so say a cell deletion delegate callback in the diffable data source can reflect the change in the model property and CloudKit database.

1

There are 1 answers

0
alekseevpg On

I believe it's really up to architecture of your choice. But it general assuming you have ViewModel(in MVVM) or Presenter(in MVP/VIPER) you should keep your model there, and then bind it to DataSource.

When deletion delegate will be hit, you need to call a delete func on your VM/Presenter, which will update this model, save it to CloudKit, and then trigger DataSource update

If you want to have a more code-oriented answer, please share an example of your code, and i'll be glad to help you out with it.