Last active
October 5, 2023 06:23
-
-
Save beechtom/e814a80461a216e29e4812a8923d917c to your computer and use it in GitHub Desktop.
SectionedResults-04
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SwiftData | |
struct SectionedResults<SectionIdentifier, Result>: RandomAccessCollection | |
where SectionIdentifier: Hashable, Result: PersistentModel { | |
struct Section: RandomAccessCollection, Identifiable { | |
typealias Element = Result | |
typealias ID = SectionIdentifier | |
typealias Index = Int | |
typealias Iterator = IndexingIterator<Self> | |
var id: ID | |
var elements: [Element] | |
var startIndex: Index = 0 | |
var endIndex: Index { elements.count } | |
subscript(position: Index) -> Element { | |
elements[position] | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment