Methods can be used to accomplish a massive variety of tasks. This video shows how to create a method in Swift 3 using Xcode 8 and iOS 10.
- [Instructor] Let's look at actually using methods in code.…Here I have a label which is connected to a label in my…storyboard right here.…I've used the techniques shown in a previous movie to do so.…So if you don't know how to set that up I recommend watching…movies in the variables chapter to see how that works.…I've set up a variable here called score.…That's an integer equal to zero.…So let's say we're making a game and every time the player…shoots an alien in the game,…then the player gets some points.…
So what we're going to do is create a method that's going…to add to the player's score and update the label…on the stream every time the player scores.…So a few lines below, where we create that score variable…I'm going to create a method called didScore.…So func keyword that's where we start, didScore camel case…parentheses and then some curly braces.…So then inside of didScore we put what happens…when the user scores.…
Well the first thing we want to do is add…to the user's score.…So we can type score equals score plus one.…
- Installing Xcode
- Creating an Xcode project
- Configuring the iOS Simulator
- Understanding variables
- Connecting visual objects to variables
- Understanding methods
- Connecting a button to a method
- Using conditional statements
- Setting up the user interface (UI)
- Building a complete iOS app
Skill Level Beginner
1. Set Up Your Coding Environment
Create an Xcode project4m 19s
2. Programming Building Blocks: Variables
3. Programming Building Blocks: Methods
4. Programming Building Blocks: Conditional Statements
5. Plan and Prepare the App
6. Build a Full Application
Next steps3m 11s
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.