Introduction to Swift Programming Language

Introduction to Swift Programming Language Part -2


         In this section i am going to explain the syntax and some rules of writing the code in swift compare to objective-C. 

         As we already know that the swift remove the some library from the objective-C so before start writing code in swift you need to

         1. Variable Declaration

              In case of Objective-C
 
                   NSString *myString = @"Hello Iphone.";


              In case of Swift
 
                   var myString = "Hello Iphone."


2.  Constant Declaration -
      

              In case of Swift
 
                   let kSomeConstant = 40 

let kSomeConstant: Int = 40

         3.  Array Declaration -

      

              In case of Swift
 
                   var colorsArray = ["Blue", "Red", "Green", "Yellow"]

var colorsDictionary = ["PrimaryColor":"Green", "SecondaryColor":"Red"]



0 comments:

Post a Comment

My Instagram