Introducing Diffable Data Source

Ever since the evolution of iOS SDK, it has been the responsibility of the data source, to provide the table-views and collection-views with the data they need to create, configure and display its cells and supplementary views. For this, we are required to implement the necessary protocol (UITableViewDataSource or UICollectionViewDataSource) methods and sync our updated data-model with the data source properly to avoid any synchronization bugs. This approach has been used for a decade now but still, it has quirks and fallout which could sometimes give you a headache.

With iOS 13.0, Apple provided a couple of really cool API’s for both table-views and collection-views. One of these cool features is Diffable Data Sources. In today’s article, I will show you how to use UICollectionViewDiffableDataSource to drive your collection-views. By the end of this article, you will know exactly how to use Diffable Data Sources and what their caveats are. But before that let’s discuss and understand why Apple had to provide a brand new API for data sources. Let’s dive in!

Read more