Skip to content

Instantly share code, notes, and snippets.

@beechtom
Last active October 5, 2023 20:24
Show Gist options
  • Save beechtom/fdecee66e9a5574b47cbda84c79a0a6c to your computer and use it in GitHub Desktop.
Save beechtom/fdecee66e9a5574b47cbda84c79a0a6c to your computer and use it in GitHub Desktop.
SectionedQuery-06
import SwiftData
@Model
class Item {
@Attribute(.unique) var name: String
var kind: String
}
struct ContentView: View {
@SectionedQuery(\.kind) private var results: SectionedResults<String, Item>
var body: some View {
List(results) { section in
Section(section.id) {
ForEach(section) { item in
Text(item.name)
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment