DiffableDataSourceSnapshot
public struct DiffableDataSourceSnapshot<SectionIdentifierType, ItemIdentifierType> where SectionIdentifierType : Hashable, ItemIdentifierType : Hashable
A class for backporting NSDiffableDataSourceSnapshot introduced in iOS 13.0+, macOS 10.15+, tvOS 13.0+.
Represents the mutable state of diffable data source of UI.
-
Creates a new empty snapshot object.
Declaration
Swift
public init() -
The number of item identifiers in the snapshot.
Declaration
Swift
public var numberOfItems: Int { get } -
The number of section identifiers in the snapshot.
Declaration
Swift
public var numberOfSections: Int { get } -
All section identifiers in the snapshot.
Declaration
Swift
public var sectionIdentifiers: [SectionIdentifierType] { get } -
All item identifiers in the snapshot.
Declaration
Swift
public var itemIdentifiers: [ItemIdentifierType] { get } -
Returns the number of item identifiers in the specified section.
Declaration
Swift
public func numberOfItems(inSection identifier: SectionIdentifierType) -> IntParameters
identifierAn identifier of section.
Return Value
The number of item identifiers in the specified section.
-
Returns the item identifiers in the specified section.
Declaration
Swift
public func itemIdentifiers(inSection identifier: SectionIdentifierType) -> [ItemIdentifierType]Parameters
identifierAn identifier of section.
Return Value
The item identifiers in the specified section.
-
Returns a section identifier containing the specified item.
Declaration
Swift
public func sectionIdentifier(containingItem identifier: ItemIdentifierType) -> SectionIdentifierType?Parameters
identifierAn identifier of item.
Return Value
A section identifier containing the specified item.
-
Returns an index of the specified item.
Declaration
Swift
public func indexOfItem(_ identifier: ItemIdentifierType) -> Int?Parameters
identifierAn identifier of item.
Return Value
An index of the specified item.
-
Returns an index of the specified section.
Declaration
Swift
public func indexOfSection(_ identifier: SectionIdentifierType) -> Int?Parameters
identifierAn identifier of section.
Return Value
An index of the specified section.
-
Appends the given item identifiers to the specified section or last section.
Declaration
Swift
public mutating func appendItems(_ identifiers: [ItemIdentifierType], toSection sectionIdentifier: SectionIdentifierType? = nil)Parameters
identifiersThe item identifiers to be appended.
sectionIdentifierAn identifier of section to append the given identiciers.
-
Inserts the given item identifiers before the specified item.
Declaration
Swift
public mutating func insertItems(_ identifiers: [ItemIdentifierType], beforeItem beforeIdentifier: ItemIdentifierType)Parameters
identifiersThe item identifiers to be inserted.
beforeIdentifierAn identifier of item.
-
Inserts the given item identifiers after the specified item.
Declaration
Swift
public mutating func insertItems(_ identifiers: [ItemIdentifierType], afterItem afterIdentifier: ItemIdentifierType)Parameters
identifiersThe item identifiers to be inserted.
afterIdentifierAn identifier of item.
-
Deletes the specified items.
Declaration
Swift
public mutating func deleteItems(_ identifiers: [ItemIdentifierType])Parameters
identifiersThe item identifiers to be deleted.
-
Deletes the all items in the snapshot.
Declaration
Swift
public mutating func deleteAllItems() -
Moves the given item identifier before the specified item.
Declaration
Swift
public mutating func moveItem(_ identifier: ItemIdentifierType, beforeItem toIdentifier: ItemIdentifierType)Parameters
identifierAn item identifier to be moved.
toIdentifierAn identifier of item.
-
Moves the given item identifier after the specified item.
Declaration
Swift
public mutating func moveItem(_ identifier: ItemIdentifierType, afterItem toIdentifier: ItemIdentifierType)Parameters
identifierAn item identifier to be moved.
toIdentifierAn identifier of item.
-
Reloads the specified items.
Declaration
Swift
public mutating func reloadItems(_ identifiers: [ItemIdentifierType])Parameters
identifiersThe item identifiers to be reloaded.
-
Appends the given section identifiers to the end of sections.
Declaration
Swift
public mutating func appendSections(_ identifiers: [SectionIdentifierType])Parameters
identifiersThe section identifiers to be appended.
-
Inserts the given section identifiers before the specified section.
Declaration
Swift
public mutating func insertSections(_ identifiers: [SectionIdentifierType], beforeSection toIdentifier: SectionIdentifierType)Parameters
identifiersThe section identifiers to be inserted.
toIdentifierAn identifier of setion.
-
Inserts the given section identifiers after the specified section.
Declaration
Swift
public mutating func insertSections(_ identifiers: [SectionIdentifierType], afterSection toIdentifier: SectionIdentifierType)Parameters
identifiersThe section identifiers to be inserted.
toIdentifierAn identifier of setion.
-
Deletes the specified sections.
Declaration
Swift
public mutating func deleteSections(_ identifiers: [SectionIdentifierType])Parameters
identifiersThe section identifiers to be deleted.
-
Moves the given section identifier before the specified section.
Declaration
Swift
public mutating func moveSection(_ identifier: SectionIdentifierType, beforeSection toIdentifier: SectionIdentifierType)Parameters
identifierA section identifier to be moved.
toIdentifierAn identifier of section.
-
Moves the given section identifier after the specified section.
Declaration
Swift
public mutating func moveSection(_ identifier: SectionIdentifierType, afterSection toIdentifier: SectionIdentifierType)Parameters
identifierA section identifier to be moved.
toIdentifierAn identifier of section.
-
Reloads the specified sections.
Declaration
Swift
public mutating func reloadSections(_ identifiers: [SectionIdentifierType])Parameters
identifiersThe section identifiers to be reloaded.
View on GitHub
DiffableDataSourceSnapshot Structure Reference