I am moving my swift project to Swift 5.5, taking advantage of async await and trying to learn the syntax effectively while I am at it.
I have been successful so far in moving some functions across - those within the FirebaseFirestore database: ".getDocuments()" and ".setData".
In these instances, the compiler recognizes what I am trying to do and suggests the 'async throws' version of the method, leaving out the completion parameter / closure. See screen shot here:

When I …
尝试以编程方式触发导航链接时遇到上述错误的问题。单击链接后,错误的目标数组元素将偶尔加载(相对于单击的标签),当然会显示上述错误。
当我以非编程方式触发导航链接时,不会发生错误,但当用户单击此链接时,我需要运行另一种方法。
我已经阅读了几个问题,例如此处和此处,但找不到我的案例的原因。
模型结构:
struct Place: Identifiable {
var id: UUID = UUID()
var name: String = ""
var testBool: Bool = false
Run Code Online (Sandbox Code Playgroud)
}
环境对象的类:(生产项目有许多属性和方法 - 本质上这是 ViewModel)
class UserPlaces: ObservableObject {
@Published var placesArray: [Place] = [Place]([Place(name: "Christian", testBool: false),Place(name: "Catherine", testBool: true)])
Run Code Online (Sandbox Code Playgroud)
}
导航布尔类:(生产项目这里有许多属性,我想将它们保留在一个类中)
class Navigation: ObservableObject {
@Published var showPlaceDetail: Bool = false
Run Code Online (Sandbox Code Playgroud)
}
ContentView:(NavigationView所在的父视图)
import SwiftUI
Run Code Online (Sandbox Code Playgroud)
结构ContentView:视图{
var body: some View {
NavigationView {
ScrollView {
Text("Hello, world!")
.padding()
CardsGrid2()
} // …Run Code Online (Sandbox Code Playgroud)