Skip to content

Commit 49197e8

Browse files
committed
Add method for get section.
1 parent a135cf2 commit 49197e8

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

Sources/SPDiffable/DataSource/SPDiffableCollectionDataSource.swift

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,11 +147,18 @@ open class SPDiffableCollectionDataSource: UICollectionViewDiffableDataSource<SP
147147
return itemIdentifier(for: indexPath)
148148
}
149149

150+
/**
151+
SPDiffable: Get sections.
152+
*/
153+
public func sections() -> [SPDiffableSection] {
154+
return snapshot().sectionIdentifiers
155+
}
156+
150157
/**
151158
SPDiffable: Get section by index.
152159
*/
153160
public func section(for index: Int) -> SPDiffableSection? {
154-
let snapshot = self.snapshot()
161+
let snapshot = snapshot()
155162
guard index < snapshot.sectionIdentifiers.count else { return nil }
156163
return snapshot.sectionIdentifiers[index]
157164
}

0 commit comments

Comments
 (0)