0

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
Andrey Nadosha
  • 262
  • 1
  • 4
  • 16
  • 3
    It should be `.disabled(selectedLanguage != nil)` without the $ sign and of course selectedLanguage needs to be declared as an optional variable, `@State private var selectedLanguage: UUID?` – Joakim Danielson Apr 17 '21 at 11:50

1 Answers1

1

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

Mahdi BM
  • 1,826
  • 13
  • 16