O'Reilly logo

iOS® 8 for Programmers: An App-Driven Approach with Swift™, Third Edition by Abbey Deitel, Harvey M. Deitel, Paul J. Deitel

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

3.6.6 ViewController Action Method calculateTip

Method 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 ...

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