Environment: Version 11.0 beta 4 (11M374r)
I'm trying to get a grip on the evolving List() syntax.
The following is a simple list of UUIDs:
Here's my attempted remedy and the compiler result.
I've created an additional error after fixing the previous warning:
I tried replacing '@State' with '@Binding'; which didn't work.
Here's the complete source code:
import SwiftUI
enum TabIdentifier {
case list
case another
}
struct TabView: View {
private var uuids: [String] = {
let ids: [String] = Array(0...5).map { _ in
UUID().uuidString
}
return ids
}()
@State private var selectedTab: TabIdentifier = .list
var body: some View {
TabbedView(selection: $selectedTab) {
// ------------------------------------------------------------
// Tab #1
NavigationView {
List(uuids, id: \.id) { uuid in
Text(uuid)
}.navigationBarTitle(Text("List of UUIDs"))
}.tabItem {
Text("List") // ...Tab #1 Label
}
.tag(TabIdentifier.list) // ...Tab #1 tag
// ------------------------------------------------------------
// Tab #2
Text("Hello Ric!")
.tabItem {
Text("Another view") // ...Tab #2 Label
}
.tag(TabIdentifier.another) // ... Tab #2 Label
}
}
}
What's the remedy?