calculateTip (Fig. 3.45) is the action (as specified by
@IBAction on line 31) that responds to the Text Field’s Editing Changed event and the Slider’s Value Changed event. Add the code in lines 32–81 to the body of
calculateTip. (If you’re entering the Swift code as you read this section, you’ll get errors on several statements that perform
NSDecimalNumber calculations using overloaded operators that you’ll define in Section 3.6.7.) The method takes one parameter. Each parameter’s name must be declared with a type annotation specifying the parameter’s type. When a view-controller object receives a message from a UI component, it also receives as an argument a reference to that component—the ...