Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- final class FormViewController: UIViewController {
- @Published var isSubmitAllowed: Bool = false
- private var switchSubscriber: AnyCancellable?
- @IBOutlet private weak var acceptTermsSwitch: UISwitch!
- @IBOutlet private weak var submitButton: UIButton!
- override func viewDidLoad() {
- super.viewDidLoad()
- switchSubscriber = $isSubmitAllowed.receive(on: DispatchQueue.main).assign(to: \.isEnabled, on: submitButton)
- }
- @IBAction func didSwitch(_ sender: UISwitch) {
- isSubmitAllowed = sender.isOn
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement