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,800 courses taught by industry experts.
Understanding methods
From the course: Programming for Non-programmers: iOS 17 and Swift 5
Understanding methods
- [Instructor] In order to move forward in our app, we need to talk about methods and functions. These are code blocks that are executed at certain times, including when a button is pressed, and that's what we're going to be focusing on in this chapter. Also, methods and functions mean slightly different things, kind of like rectangles and squares. But for the purpose of this course, it's not really important how to differentiate them. So I may use them interchangeably. So let's talk about what methods are. Methods are the actions of programming, and they're similar to verbs in spoken language. They do things. In other words, they are named, logically grouped commands. Think of jumping. If you wanted to jump, you have to bend your knees, push down on the ground, and propel yourself up into the air. If you were to write a method called jump, then you would have all of that logic about bending your knees and pushing down and everything in there inside of the method. It's also important…
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 methods5m 30s
-
(Locked)
Using methods3m 47s
-
(Locked)
Running code when a button is pressed3m 43s
-
(Locked)
Using a method as a variable4m 46s
-
(Locked)
Passing parameters to method variables3m 24s
-
(Locked)
SwiftUI binding5m 21s
-
(Locked)
Using different methods to handle different events3m 2s
-
(Locked)
Challenge: Create methods for the equal button52s
-
(Locked)
Solution: Create methods for the equal button48s
-
(Locked)
-
-
-