Diffable data sources were introduced at WWDC 2019 and have been available since iOS 13. They’re a replacement for the good old UICollectionViewDataSource and UITableViewDataSource protocols and make it easier to migrate changes in your data views.

Diffable data sources come with a few benefits over using the classic data source approach and are the preferred way nowadays to work with collection and table views. However, it might not always be easy to rewrite existing code that is heavily integrated into using the old approach. This is too bad, as it takes away the opportunity to benefit from this great new API.

Therefore, I’ve decided to introduce you to a simple extension of diffable data sources that allows you to integrate this in existing projects without too much hassle. But before we dive in, let’s first take a look at what diffable data sources are and what kind of benefits they bring.

What Are Diffable Data Sources?

A diffable data source provides the behavior you need to manage updates to your table or collection view’s data and UI in a simple, efficient way. It replaces well-known methods like cellForRowAtIndexPath: and numberOfItemsInSection:.

#ios #xcode #programming #swift #mobile #data-science

Adopt Diffable Data Sources With Ease
1.25 GEEK