Post

Replies

Boosts

Views

Activity

Reply to List with selection: SelectionManagerBox<UUID> tried to update multiple times per frame.
Hi @DTS Engineer, thanks for responding. The page you pointed me to claims that The forums have a list of websites you can link to, but I have yet to find this. I have successfully reproduced the issue using the following steps: Create a SwiftData app File...New...Project -> macOS...App...Next -> SwiftData I called mine IssueTest Edit Item.swift: add the Identifiable protocol add a property var id = UUID() Edit ContentView.swift: add @State private var selection: Item.ID? add selection to List: List(selection: $selection) Run the app and do: click on the '+' to add one or more entries click on any of the list items the message should appear immediately Here is the (git) diff from the project's auto-generated repo: diff --git a/IssueTest/ContentView.swift b/IssueTest/ContentView.swift index 0141127..e369ee2 100644 --- a/IssueTest/ContentView.swift +++ b/IssueTest/ContentView.swift @@ -11,10 +11,11 @@ import SwiftData struct ContentView: View { @Environment(\.modelContext) private var modelContext @Query private var items: [Item] + @State private var selection: Item.ID? var body: some View { NavigationSplitView { - List { + List(selection: $selection) { ForEach(items) { item in NavigationLink { Text("Item at \(item.timestamp, format: Date.FormatStyle(date: .numeric, time: .standard))") diff --git a/IssueTest/Item.swift b/IssueTest/Item.swift index d06b484..fba89db 100644 --- a/IssueTest/Item.swift +++ b/IssueTest/Item.swift @@ -9,7 +9,8 @@ import Foundation import SwiftData @Model -final class Item { +final class Item: Identifiable { + var id = UUID() var timestamp: Date init(timestamp: Date) { And here's a snapshot of the error:
Aug ’24