From the course: Programming for Non-programmers: iOS 17 and Swift 5

Unlock this course with a free trial

Join today to access over 24,500 courses taught by industry experts.

Solution: Create methods for the equal button

Solution: Create methods for the equal button

- [Narrator] Here's a solution to this chapter's challenge. I'm just going to copy and paste the clearWasPressed method, just like that, I'll change clear to equal, both in the name of the method and in the print statement. And then I'm just going to copy and paste the action clear was pressed, and the comma on the line above the calculator button constructor, and I'll paste it into the calculator button constructor for the equals button just like that, just before the close parenthesis there. And then I'm going to change the method name to equalWasPressed, and that should be it. So I can show the debug area to view the print statement. And there it is, and the other buttons continue to work, and that solves this chapter's challenge.

Contents