Questions tagged [uicollectionviewdiffabledatasource]
75 questions
1
vote
0 answers
How to apply multiple NSDiffableDataSourceSectionSnapshot at once?
I'm building UICollectionView with new diffable NSDiffableDataSourceSnapshot and NSDiffableDataSourceSectionSnapshot. I need to use NS…SectionSnapshot to populate my UICollectionView with outline items.
First, I create NS…Snapshot, set all section…

pacification
- 5,838
- 4
- 29
- 51
1
vote
0 answers
How to use multiple data types in Diffable datasource?
I have a collection view with 4 sections that each section have a different Item type. How should I achieve this with UICollectionViewDiffableDataSource?
I tried AnyHashable and enum associated values but I cant figured it out how should I use it on…

Mobin Jahantark
- 140
- 9
1
vote
1 answer
How to model updated items with UICollectionViewDiffableDataSource
I'm struggling to understand how to use UICollectionViewDiffableDataSource and NSDiffableDataSourceSnapshot to model change of items.
Let's say I have a simple item which looks like this:
struct Item {
var id: Int
var name: String
}
Based…

kjam
- 809
- 1
- 7
- 17
1
vote
2 answers
Hide empty section in Compositional Layout Collection View with DiffableDataSource not working
I have three sections of data on screen: one for Five Star Items, one for Visits, and one for Other Fun Places items. They are all of the same type: funPlaces. For this example, I'm creating three arrays of funPlaces and showing them in three…

Kent
- 1,705
- 3
- 16
- 26
1
vote
2 answers
How to scroll to an IndexPath after apply the snapshot
Im facing issue that is related to scroll to IndexPath after collection view snapshot applied.
For this I have write bellow code
dataSource.apply(snapshot, animatingDifferences: false, completion: {
…

Rajasekhar Pasupuleti
- 1,598
- 15
- 22
1
vote
1 answer
How do I support the fast-scrolling scrubber using UICollectionViewDiffableDataSource?
I have a UICollectionView that I feed data into using UICollectionViewDiffableDataSource. I want to display a scroll scrubber on the trailing edge of it, like I'd get if I implemented the data source methods indexTitlesForCollectionView and…

Tom Hamming
- 10,577
- 11
- 71
- 145
1
vote
0 answers
Using Custom CollectionView layout with NSDiffableDataSource
I'm trying to use NSDiffableDataSource with my custom CollectionView layout. The position and size of each cell depends on the number of elements in the collection. It also uses UIDynamicAnimator to produces springy behaviour. The problem is when a…

Artemis Shlesberg
- 308
- 2
- 10
1
vote
1 answer
Where do the parameters come from in the UICollectionViewDiffableDataSource closure?
Having trouble understanding the closure in UICollectionViewDiffableDataSource, particularly what's being passed into it. All of the tutorials I can find explain what to type but not why, and I'm still a bit new to Swift and programming.
I'm…

JBZic
- 53
- 6
1
vote
1 answer
Data not display in collectionView DiffableDataSource MVVM RxSwift
I'm learning MVVM and RxSwift, and I want to display data from GitHub api and populate into collectionViewDiffableDataSource. But it's not displaying my data, even with my snapshot is already setup to accept my data. This is my code
class…

ferryawijayanto
- 569
- 4
- 18
1
vote
1 answer
Invalid parameter not satisfying: initialSnapshot.numberOfSections == initialSections.count
Working on a new project, our team decided to use UICollectionViewDiffableDataSource to handle our collection views. It works fine, but we're getting (infrequent) crashes logged via an online tool with the message Invalid parameter not satisfying:…

TomQDRS
- 875
- 1
- 7
- 20
1
vote
2 answers
Why is it possible to write the UICollectionViewDiffableDataSource initializer in this strange way?
While learning Swift via Paul Hudsons's tutorial, I came across something strange.
The initializer of UICollectionViewDiffableDataSource is defined as:
public init(collectionView: UICollectionView, cellProvider: @escaping…

codingChicken
- 191
- 12
1
vote
0 answers
Limit size of diffable data source snapshots after calling performFetch
Problem
After executing an NSBatchBatchInsertRequest and calling fetchedResultsController.performFetch(), the frc’s delegate method controller(_:didChangeContentWith:) is called with a NSDiffableDataSourceSnapshot that…

Alex Walczak
- 1,276
- 1
- 12
- 27
1
vote
0 answers
UICollectionViewDiffableDataSource Animations
Is it true that there’s no way to animate cells being added and removed using a UICollectionViewDiffableDataSource like there is using a UITableViewDiffableDataSource ? Looks like the tableView version has defaultRowAnimation property but nothing…

bdc
- 178
- 1
- 12
1
vote
0 answers
DiffableCollectionViewDataSource with different cell registrations
I've been trying to make a section for diffable collection view data source that could have a list of GenericItem where this class would have a property cellRegistration that would be of type UICollectionView.CellRegistration. After this class every…

Eric
- 57
- 6
1
vote
1 answer
UICollectionViewDiffableDataSource: Request for number of items in section 0 when there are only 0 sections in the collection view
I am trying to make a timeline where each section is a day and each day has many items (records).
Here is my section (day) class:
class YearMonthDay: Comparable, Hashable {
let year: Int
let month: Int
let day: Int
init(year:…

BigBoy1337
- 4,735
- 16
- 70
- 138