Swift in iOS: Getting Started


The Basics : Swift is programming language for iOS, macOS, watchOS, and tvOS app development and many parts of its,  familiar from  developing in C and Objective-C.
Get the Tools
To develop iOS apps using the latest technologies described in these lessons, you need a Mac computer running the latest version of Xcode. Xcode includes all the features you need to design, develop, and debug an app.
To download the latest version of Xcode
1. Open the App Store app on your Mac (by default it’s in the Dock).
2. In the search field in the top-right corner, type Xcode and press the Return key.
3. The Xcode app shows up as the first search result.
4. Click Get and then click Install App.
5. Enter your Apple ID and password when prompted.
6. Xcode is downloaded into your /Applications directory.

NOTE: Swift code can run in  a playground. There you can learn Swift Programming Language. It gives you experiment with code and see the results immediately, without the overhead of building and running an app.



Constants and Variables: The both variable and constants are mean to storage location name, identified by a memory location , paired with its associative name or identifier having some quantity of information or value. 
// Variable Syntax:
var variable_name_here :Data Type = <initial value>
e.g1.  var strMyName : String = "Rashpinder"
e.g2. var numberOfApples :Int = 10 
e.g3  var arrayOfPeoples : [String] = ["Rash", "Loki", "jazz", "sachin"]
e.g4  var countryMobileCode : [String:Int] = ["india":91, "canada":1, "aus":64, "pakistan": 92]

Important Note : When declare variable , it not sure that we have initial value at the time of declare variable: 
e.g1.  var strMyName : String 
e.g2. var numberOfApples :Int  
e.g3  var arrayOfPeoples : [String]
e.g4  var countryMobileCode : [String:Int]

strMyName  = "Rashpinder"
numberOfApples = 10 
arrayOfPeoples =  ["Rash", "Loki", "jazz", "sachin"]
countryMobileCode = ["india":91, "canada":1, "aus":64, "pakistan": 92]
countryMobileCode = ["india":91, "canada":1]
numberOfApples = 30 



Note :As we can start developing Apps in Swift , there is most usable advantage of Swift is TypeInference , in which declare variable with initial value , don’t need to define Data Type (Int, Float, Array, Dictionary ). 

Important Note: Any type variable can assign any value to it. 

var anyType : Any
anyType = “100”
anyType = [“Array of String assign”]

anyType = “You can change to any type of Data Type”

//Constant Syntax:

let cons_name_here :Data Type = <initial value>
e.g1. let strMyName : String = "Rashpinder"
e.g2.let numberOfApples :Int = 10 
e.g3 let arrayOfPeoples : [String] = ["Rash", "Loki", "jazz", "sachin"]
e.g4 let countryMobileCode : [String:Int] = ["india":91, "canada":1, "aus":64, "pakistan": 92]

Important Note : When declare constant , it not sure that we have initial value at the time of declare constant but once any value assigned to constant, then that value never change till lifetime of constant in memory. 


Let’s get started!
Subscribe to this blog to get notifications about new stories from Swift and iOS Development.











Comments

Popular posts from this blog