Hi,
I am inexperienced hobbyist programmer in the Xcode environment and the swift language.
I have a very basic question:
I read the documentation about one of the NavigationSplitView initializers:
init(sidebar: () -> Sidebar, detail: () -> Detail)
I created two basic views the SidebarView and the DetailsView.
The following code, use the views above as parameters but gives errors, and I cannot understand why.
import SwiftUI
struct ContentView: View {
var body: some View {
NavigationSplitView(sidebar: SidebarView(), detail: DetailsView())
}
}
#Preview {
ContentView()
}
I am interested to understand how the swift language works, and how to implement the documentation of swiftUI in real code.
Is there any way to use the views as parameters and not in brackets?
import SwiftUI
struct ContentView: View {
var body: some View {
NavigationSplitView {
SidebarView()
} detail: {
DetailsView()
}
}
}
#Preview {
ContentView()
}
2
0
422