Skip to content

Commit 52c22fd

Browse files
committed
Added sections getter for table data source.
1 parent 5093418 commit 52c22fd

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

Sources/SPDiffable/DataSource/SPDiffableTableDataSource.swift

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,22 @@ open class SPDiffableTableDataSource: UITableViewDiffableDataSource<SPDiffableSe
9393
return itemIdentifier(for: indexPath)
9494
}
9595

96+
/**
97+
SPDiffable: Get sections.
98+
*/
99+
public func sections() -> [SPDiffableSection] {
100+
return snapshot().sectionIdentifiers
101+
}
102+
103+
/**
104+
SPDiffable: Get section by index.
105+
*/
106+
public func section(for index: Int) -> SPDiffableSection? {
107+
let snapshot = snapshot()
108+
guard index < snapshot.sectionIdentifiers.count else { return nil }
109+
return snapshot.sectionIdentifiers[index]
110+
}
111+
96112
/**
97113
SPDiffable: Get index path for item by identifier.
98114
*/

0 commit comments

Comments
 (0)