1
0
mirror of https://github.com/metabolist/metatext synced 2024-12-26 17:52:26 +01:00
metatext-app-ios-iphone-ipad/Extensions/Array+Extensions.swift
Justin Mazzocchi 3b0f0bf82f
wip
2021-01-01 12:46:29 -08:00

26 lines
676 B
Swift

// Copyright © 2020 Metabolist. All rights reserved.
import UIKit
extension Array where Element: Sequence, Element.Element: Hashable {
func snapshot() -> NSDiffableDataSourceSnapshot<Int, Element.Element> {
var snapshot = NSDiffableDataSourceSnapshot<Int, Element.Element>()
let sections = [Int](0..<count)
snapshot.appendSections(sections)
for section in sections {
snapshot.appendItems(self[section].map { $0 }, toSection: section)
}
return snapshot
}
}
extension Array where Element: Hashable {
func snapshot() -> NSDiffableDataSourceSnapshot<Int, Element> {
[self].snapshot()
}
}