我花了几个小时试图摆脱我的应用程序上的错误消息:
\nList with selection: SelectionManagerBox<String> tried to update multiple times per frame.\nRun Code Online (Sandbox Code Playgroud)\n这是一款 macOS 14 应用程序。由于我无法找到解决方案,因此我决定尝试创建一个最小的可重现示例。这是这个例子:
\nimport SwiftUI\n\nstruct ContentView: View {\n @State var selection: String = ""\n @State var secondSelection: String = ""\n \n var body: some View {\n NavigationSplitView {\n List(selection: $selection) {\n NavigationLink("A", value: "A")\n NavigationLink("B", value: "B")\n NavigationLink("C", value: "C")\n }\n } content: {\n List(selection: $secondSelection) {\n NavigationLink("1", value: "1")\n NavigationLink("2", value: "2")\n NavigationLink("3", value: "3")\n }\n } detail: {\n Text("\\(selection) - \\(secondSelection)")\n }\n …Run Code Online (Sandbox Code Playgroud)