This post will tell you about the basic types of variables.
First of all, there are no semicolons in Swift (*does the happy dance*). That means no more endless searching for that one semicolon that you missed that messed everything up.
All variables are declared using var. Sometimes, xCode is smart enough to recognize the type of variable, so that is the only thing you need. For example:
var str = ''Probably Rainbow Unicorns" // str will automatically be set as a String
var count = 1 // count will automatically be set as an Int
var toggle = true // toggle will be set as a bool
Some of you may already see the problem. What if count is actually a double? You could declare it as
var count = 1.00
but there is a better way to do this. The colon! You can declare the type of variable using a colon after the variable name.
var counter: Double = 1
var str1: String = "Definitely Rainbow Unicorns"
At times, however, you know you need a variable, but you don't want it to have a value yet. For example, if you want a user to sign up for an account on your app, you know that user is going to create a username and password.
Student whose life is currently a dark swirly void of confused bird noises.