O'Reilly logo

Learning iOS UI Development by Yari D'areglia

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Sending actions

The ThermostatSlider implementation is almost complete; we are just missing a way to communicate the change of the current value, exactly as a common UISlider class does with the object subscribed to its value update.

The UIControl class provides methods to handle the target-action pattern in a really easy way; you can add a new target object with addTarget(_:action:forControlEvents:) specifying the action and event to which to subscribe. Then, you can remove this with the removeTarget(_:action:forControlEvents:) method. The list of targets subscribed to the control events can be retrieved using the allTargets() method. You can even obtain the name of the action called when a given event is triggered on a target using actionsForTarget(_:forControlEvent:) ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required