Thursday, 25 September 2014

Best iOS interview questions on swift programming language

I started this post to all  iOS developers/beginners to prepare your self for Swift Interview questions. As its time to prepare with Swift interview questions. Swift is going to replace objective-c so we all have to prepare for best iOS interview questions on swift.

What is Swift ?


Swift will replace Objective-C as the primary language in which iPhone and Macintosh applications are written.

How we declare variables in Swift ?

Constants and variables must be declared before they are used. Declare constants with the 'let' keyword and variables with the 'var' keyword.

What is difference between 'let' and 'var' declaration ?

constants are expressed with the ‘let’ keyword. So once assigned value can not be change, but assigned values using 'var' keyword can be change.

In terms of objective -c or compare with  objective -c, 'var' is  Mutable and  'let' is NonMutable.

let kMyConstant = 40
let  kMyConstant: Int = 40

var myString = "This is my string."

What is Initialization ?

You implement this initialization process by defining initializers, which are like special methods that can be called to create a new instance of a particular type. Unlike Objective-C initializers, Swift initializers do not return a value. Their primary role is to ensure that new instances of a type are correctly initialized before they are used for the first time. 

Initializers are called to create a new instance of a particular type. In its simplest form, an initializer is like an instance method with no parameters, written using the init keyword:
init() {
// perform some initialization here

In Swift How to connect UI under Swift Environment ?

UI connectivity has no change, its similar to objective-c. Xib/Storyboard under Interface builder.

1 comment: