Skip to content

Commit a000880

Browse files
committed
Added getter for section.
1 parent 3795529 commit a000880

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

Sources/SPDiffable/DataSource/SPDiffableCollectionDataSource.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,15 @@ open class SPDiffableCollectionDataSource: UICollectionViewDiffableDataSource<SP
124124
return itemIdentifier(for: indexPath)
125125
}
126126

127+
/**
128+
SPDiffable: Get section by index.
129+
*/
130+
public func section(for index: Int) -> SPDiffableSection? {
131+
let snapshot = self.snapshot()
132+
guard index < snapshot.sectionIdentifiers.count else { return nil }
133+
return snapshot.sectionIdentifiers[index]
134+
}
135+
127136
/**
128137
SPDiffable: Get index path for item by identifier.
129138
*/

0 commit comments

Comments
 (0)