Closed zmarvin closed 7 years ago
Can u provide a use case?
There are many signals that produce errors, such as network requests, loading local data, and so on. So when the switch affects such a signal, you need to wait for the appearance of the results to determine whether to change the state of the switch.
The did change state is unnecessary. You should use this instead:
runkeeperSwitch.addTarget(self, action: #selector(ViewController.switchValueDidChange(sender:)), for: .valueChanged)
Also the will change might not be necessary. You can always fork and add that. Ill ask the owner of the repo.
You're right, this is just my advice, depending on the author's meaning, Cocoa had a lot of controls to achieve a similar protocol.
Sorry, but I believe that it is not needed.
I think add two protocol methods to communicate with the outside, so that before the switch state changes, give the user an opportunity to choose whether or not to change.