Join Todd Perkins for an in-depth discussion in this video Understanding variables, part of Programming for Non-Programmers: iOS 7.
- View Offline
…Variables are the most basic building blocks of programming.…So what are variables?…They are the nouns of programming.…And that means that they are named containers that hold data.…This data can be a number, text, or more complicated value.…For example, a user's score in a game would be held in a number variable.…In code, variables are created by declaring the data type.…
So, for example, if the variable is going to be a number,…you want to declare that the variable will be holding number data.…Variable has a name.…For example, if you're going to create a score…in a game, you could call that variable score.…You set the value of a variable using an equal sign.…And you end programming statements with a semicolon.…Think of it like a period in a sentence.…
So let's look at an example of a variable in code.…This line of code creates a number variable called…score and sets it to the value of 100.…The first word is int.…Int is the data type of a variable.…That says that the variable is going to be an integer, or a whole number.…
If you find you'd like to learn more, see iOS App Development Essential Training, Foundations of Programming: Fundamentals, or any of the other programming courses in our library.
- Installing Xcode
- Creating an Xcode project
- Configuring the iOS Simulator
- Understanding variables
- Connecting visual objects to variables
- Understanding functions, methods, and selectors
- Connecting a button to a function
- Using conditional statements
- Setting up the user interface
- Connecting code elements to build an app