Hello. I have a picker that uses an enum to populate itself. There is a class called "user" that has a variable called "defaultTab". This is what's being used as the selection for the picker.
That is the enum.
That is the class, and below is the picker.
This picker is inside of a Section that is inside of a List. When I make a selection, it does not change the picker. How can I resolve this issue?
Code Block enum Tab: String, CaseIterable { case data = "Data" case transactions = "Transactions" case user = "User" var id: String {self.rawValue} }
That is the enum.
Code Block import SwiftUI class User: ObservableObject { var name: String var sources: [Source] var accounts: [Account] var categories: [Category] var transactions: [Transaction] var defaultTab: Tab init(name: String, sources: [Source], accounts: [Account], categories: [Category], transactions: [Transaction], defaultTab: Tab) { self.name = name self.sources = sources self.accounts = accounts self.categories = categories self.transactions = transactions self.defaultTab = defaultTab } }
That is the class, and below is the picker.
Code Block Picker("Default tab", selection: $user.defaultTab) { ForEach(Tab.allCases, id: \.self) { kind in Text(kind.rawValue) .tag(kind as Tab) } }
This picker is inside of a Section that is inside of a List. When I make a selection, it does not change the picker. How can I resolve this issue?