Variable declaration in Swift
Declaration of iVar:
Let's start with declaring iVars in SwiftIn Swift we can declare an iVar using keyword:
1. let - it declares an immutable iVar
2. var - it declares a mutable iVar
let myLetObject = "My immutable iVar"
So now i cannot change the value of myLetObject after it is once assigned.
var myVarObject = "My mutable iVar"
myVarObject = "Changed the value of iVar"
I can change its value at any instance.
Some examples of declaring objects:
let luckyNumber = 9
let myAge = NSInteger(27)
var myHeight = 5.5
let myImage = UIIMage(named:"MyPhoto.png")
var myName: NSString = NSString"string:Suraj Ramjan Mirajkar"
var tableView: UITableView!
Comments
Post a Comment