So far, the application has control for the text fields and the date picker, but it still needs to ask the user their gender. To fix this, we have two buttons with an image of an empty circle on them. These buttons work as radio buttons; when one of them is selected, the other one should be deselected. Why don't we use a switch instead? A switch has two states, on and off, and here, we would like a third state that is not is selected, which means that there is no gender selected by default.
Once the user has tapped on the gender button, it doesn't matter which one, the corresponding signal must be valid. How can we do this? It's very easy: first, we have to take the TouchUpInside
signal of each button, and map it to the true
value of a Boolean. Let's visualize it by placing the following code before the combineLatest
call:
let womanSignal = womanButton.rac_signalForControlEvents(.TouchUpInside).map { (signal) -> AnyObject in return...