DiffableDataSourceFilter
public final class DiffableDataSourceFilter<T, S> where T : Hashable, S : Hashable
Class adapter to provide section filter. Based on the filter function DiffableDataSource
decides
what goes into a particular section.
- Generic type
T
stands for type of a model. - Generic type
S
stands for the unique ID of a Section
Usage Example
- Assuming we have the next model:
enum TextModelMockType: String {
case type1
case type2
case type3
}
/// Type represent unique item
/// Text is something that is dynamic and can be changed
struct TextModelMock: Hashable {
let text: String
let type: TextModelMockType
func hash(into hasher: inout Hasher) {
hasher.combine(type)
}
static func == (lhs: Self, rhs: Self) -> Bool {
lhs.text == rhs.text
}
}
-
Undocumented
Declaration
Swift
public init(id: S, filter: ((T) -> Bool)? = nil)