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

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…

Contents