Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Learning iOS UI Development

You're reading from   Learning iOS UI Development Implement complex iOS user interfaces with ease using Swift

Arrow left icon
Product type Paperback
Published in Dec 2015
Publisher
ISBN-13 9781785288197
Length 196 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Toc

Table of Contents (11) Chapters Close

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:). The method we will use to inform subscribed objects that our control value is updated is sendActionsForControlEvents(_:). You encountered this at the end of the implementation of the setter for the value property:

self.sendActionsForControlEvents...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €18.99/month. Cancel anytime