I am attempting to detect changes of a UISlider value using the observer option but I am not getting any output. Selected parts of code here
class MainViewController: UIViewController {
@IBOutlet weak var speedSlider: UISlider!
var speedSliderObserver: NSKeyValueObservation?
override func viewDidLoad() { super.viewDidLoad() setSettings() }
func setSettings() {
speedSliderObserver = speedSlider.observe(.value, options: [.old, .new]) { object, change in print("speedSlider from: (change.oldValue!), to: (change.newValue!)") } }
Am I using observe correctly or is there some other way?