Swift: How to use optional in ternary check for disabling button

167 Views Asked by At

I have a simple task for JS, and I have no idea how to make it using Swift. Help me please to understand and make this.

I need just check if state value is or not nil, and disable the button.

Button(action: {onBoardingNav.goTo(step: 3)} ) {...}
    .disabled($selectedLanguage != nil)

// Error: Type 'Binding<UUID?>' is not optional, value can never be nil
1

There are 1 best solutions below

0
On

If .disabled(selectedLanguage != nil) did not work (notice no $), then try .disabled($selectedLanguage.wrappedValue != nil)