Questions tagged [diffabledatasource]

92 questions
6
votes
0 answers

iOS table view diffable data source and prefetch

What is the correct way of using NSDiffableDataSourceSnapshot and - (void)tableView:(nonnull UITableView *)tableView prefetchRowsAtIndexPaths:(nonnull NSArray *)indexPaths. It seems that every time prefetch reloads table view, table…
Martin Berger
  • 1,639
  • 3
  • 18
  • 39
6
votes
6 answers

Swift: Please specify a valid section definition when content is to be rendered for a section. This is a client error

I'm currently working on a simple IOS app using a collection view and diffable datasource. I initalize the everything in the view controller's config and call a reloadView-function every time I update the source data. The app crashes with the…
Schurigeln
  • 189
  • 1
  • 7
6
votes
0 answers

iOS UICollectionViewDiffableDataSource reloads all data with no changes

I have a simple UICollectionView with 1 section and 1 item type powered by new iOS 13 UICollectionViewDiffableDataSource. Even with no changes to data source (identical hashValues), UICollectionViewDiffableDataSource updates whole collection view…
6
votes
3 answers

self captured by a closure before all members were initialized - but I did initialize them

This is a toy example but it reduces exactly the situation I'm in: class MyDataSource: UITableViewDiffableDataSource { var string : String? init(string:String?) { self.string = string super.init(tableView:…
matt
  • 515,959
  • 87
  • 875
  • 1,141
5
votes
5 answers

TableView scrolling to top after applying UITableViewDiffableDataSource snapshot

I'm doing pagination using UITableViewDataSourcePrefetching. The values will be taken from the Realm local storage. I will get an array of objects. These values will be applied to the existing UITableViewDiffableDataSource datasource. After applying…
5
votes
3 answers

How to update footer in Section via DiffableDataSource without causing flickering effect?

A Section may contain 1 header, many content items and 1 footer. For DiffableDataSource, most of the online examples, are using enum to represent Section. For instance func applySnapshot(_ animatingDifferences: Bool) { var snapshot = Snapshot() …
Cheok Yan Cheng
  • 47,586
  • 132
  • 466
  • 875
5
votes
2 answers

How can a diffable collection view display the same item in multiple sections?

My app presents an emoji keyboard like Apple's where the emoji are displayed by-category. I render this using a collection view where the categories are sections. If an emoji has been inserted recently, it should appear in the "Frequently Used"…
Jeffrey Wear
  • 1,155
  • 2
  • 12
  • 24
5
votes
1 answer

Collection View Diffable Data Source cells disappearing and not resizing properly?

I'm having a really weird issue with my collection view. I'm using the Compositional Layout and Diffable Data Source APIs for iOS 13+, but I'm getting some really weird behavior. As seen in the video below, when I update the data source, the first…
5
votes
1 answer

Applying NSDiffableDataSourceSnapshot to UICollectionViewDiffableDataSource causes 'NSInternalInconsistencyException'

I am trying to implement a UICollectionViewDiffableDataSource for my collectionView. My code compiles fine, however I keep running into this error the first time I apply a snapshot to it, with the following error: Terminating app due to uncaught…
5
votes
1 answer

Creating a section title with UITableViewDiffableDataSource

I'm tinkering a bit with UITableViewDiffableDataSource and I'm able to get a tableView to load without issue. I'm trying to create section headers in the tableView, however I've encountered some flakey behavior. The section enum enum defined as…
Adrian
  • 16,233
  • 18
  • 112
  • 180
4
votes
1 answer

Diffable datasource performance issues with > 20K rows

I run into performance issues with the diffable data source when having a larger data set, around 22,000 items. I am surprised that applying the snapshot takes so much time when animation is ON. See the code section: let shouldAnimate =…
4
votes
0 answers

Animation Glitch When Deleting UICollectionViewDiffableDataSource Item From Context Menu

I have adopted the new UICollectionViewDiffableDataSource. I am applying a datasource snapshot everytime I delete an item: var snapshot = NSDiffableDataSourceSnapshot
3
votes
1 answer

DiffableDataSource re-create all section after update array

I created a struct for UICollectionViewDiffableDataSource struct Section: Hashable { let name: String let items: [Int] } And created snapshot with this structure func updateData(for data: [Section]) { var snapshot =…
3
votes
0 answers

collectionView inside the tableView using diffable data source

I've an issue when using the collectionView inside the tableViewCell XiB using diffable data source.Two sections I want to display like mens and womens.I don't know how to iterate the each case and display the record accordingly please check the…
Faheem
  • 97
  • 5
3
votes
1 answer

How to handle empty state when using diffable data source - UICollectionViewDiffableDataSource?

When using traditional UICollectionView, we often use the following code to handle empty state: func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { if items.count == 0 { // Display empty…