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:
Post
Replies
Boosts
Views
Activity
BTW, I see the same error when running the Book Club sample (unmodified) from the Bringing multiple windows to your SwiftUI app page.
https://developer.apple.com/documentation/swiftui/bringing_multiple_windows_to_your_swiftui_app