From the course: Programming for Non-Programmers: iOS 16 and Swift 5
Unlock the full course today
Join today to access over 24,000 courses taught by industry experts.
Solution: Create methods for the equal button
From the course: Programming for Non-Programmers: iOS 16 and Swift 5
Solution: Create methods for the equal button
(uplifting music) - [Instructor] Here is a solution to this chapter's challenge. I'm inside of Button Grid and then I'm going to create my equal was pressed method. So I'm going to copy and paste, the clear was pressed method and then just change clear to equal in both cases. Right there and right there. Then scroll up, find the equals button in your grid row and then add the action. So action after the comma and then set it equal to, equal was pressed. I'm again going to delete the parenthesis and the parameter name. And that's really it. At this point, you should be able to run the application and then click all the buttons and make sure that that print statement is running. So I'm going to press clear and then equals and then these mode buttons and then equals and clear. And let's see what we have inside of our output. Now I don't see anything right here and that's because this area that shows those print…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
(Locked)
Understanding methods6m 31s
-
(Locked)
Using methods3m 57s
-
(Locked)
Running code when a button is pressed4m 15s
-
(Locked)
Using a method as a variable5m 14s
-
(Locked)
Passing parameters to method variables4m 21s
-
(Locked)
SwiftUI binding6m 34s
-
(Locked)
Using different methods to handle different events4m 16s
-
(Locked)
Challenge: Create methods for the equal button1m 4s
-
(Locked)
Solution: Create methods for the equal button1m 37s
-
(Locked)
-
-
-