Skip to content

Instantly share code, notes, and snippets.

@beechtom
Last active October 5, 2023 06:26
Show Gist options
  • Save beechtom/7ed4ef606abfb732d01e1ae42c0b75a9 to your computer and use it in GitHub Desktop.
Save beechtom/7ed4ef606abfb732d01e1ae42c0b75a9 to your computer and use it in GitHub Desktop.
SectionedResults-05
import SwiftData
struct SectionedResults<SectionIdentifier, Result>: RandomAccessCollection
where SectionIdentifier: Hashable, Result: PersistentModel {
struct Section: RandomAccessCollection, Identifiable {
var id: SectionIdentifier
var elements: [Result]
var startIndex: Int = 0
var endIndex: Int { elements.count }
subscript(position: Int) -> Result {
elements[position]
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment