You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I found that when using a function as the @AppStorage key the function fails to infer the enum type causing an error (case 1, when typing 'Tab.tag(.welcome)').
By typing 'Tag.welcome' it fixes the error, although this is not needed outside the @AppStorage() wrapper.
But if you use a function parameter label it also fails to compile (case 3, when typing 'Tab.tag(key: Tab.welcome').
Here's a simplified test:
struct ContentView: View {
....
// 1. Desired option. Doesn't work
@AppStorage(Tab.tag(.welcome)) var selectedTab1: Int = 0
// 2. Verbose option. It works
@AppStorage(Tab.tag(Tab.welcome)) var selectedTab2: Int = 0
// 3. Parameter labels don't work
@AppStorage(Tab.tag(key: Tab.welcome)) var selectedTab3: Int = 0
}
enum Tab : String, Hashable {
case welcome, home, settings
static func tag(_ key: Tab) -> String { key.rawValue }
static func tag(key: Tab) -> String { key.rawValue }
}
The text was updated successfully, but these errors were encountered:
I found that when using a function as the @AppStorage key the function fails to infer the enum type causing an error (case 1, when typing 'Tab.tag(.welcome)').
By typing 'Tag.welcome' it fixes the error, although this is not needed outside the @AppStorage() wrapper.
But if you use a function parameter label it also fails to compile (case 3, when typing 'Tab.tag(key: Tab.welcome').
Here's a simplified test:
The text was updated successfully, but these errors were encountered: