Anzor Student
Anzor Student

Reputation: 1

Diffable Data Source cache clean up

I use DiffableDataSource for my TableView and was surprised when I found that the TableView in this case caches previously created cells after a new table update. It seems that this is implemented to store cell states and quickly update if the contents of the table change.

Because of this mechanism, I have the following problem: my cells use reference-type view models, which in turn contain notification servers from the file upload service. The view model is connected to the cell by means of a closure, which is called upon notification and updates, for example, the progress scale in the cell

After uploading the file, I make a new applySnapshot using similar models with same observers (but, for example, the file name field is already different).

Due to caching of cells in memory, the old view models with observers are not deleted, as a result, I get two observers, for two different cells, one of which is visible, and the second is not. To summarize, my question is, is it possible to disable cell caching or clean the cache if using Diffable Data Source manually?

I tried everything, no memory leak detected

Upvotes: 0

Views: 66

Answers (0)

Related Questions