Latest iOS Interview Questions & Answers 2018 - Swift 4 Tutorials W3Schools

Hot

Post Top Ad

22 Oct 2017

Latest iOS Interview Questions & Answers 2018


Top 15 2017 2018 Swift Interview Questions & Answers pdf,10 Basic Swift Interview Questions to Practice with,25 ios interview questions and answers for junior developers,ios developer interview questions for experienced,swift 3.0 interview questions,swift technical questions,advanced swift interview questions,swift 4 interview questions

Question 1:

class Person {
    var name: String
    var age: Int
    init(name: String, age: Int) {
        self.name = name
        self.age = age
    }
}

let person1 = Person(name: "John", age: 26)
var person2 = person1
person2.name = "Mike"

What's the value of person1.name and person2.name Would this be any different if Person was a class? Why?

Answer:

Both person1.name and person2.name are Mike.

Classes in Swift are reference types, and they are copied by reference rather than value. The following line creates a copy of person1 and assigns it to person2:

var person2 = person1

From this line on, any change to person1 will reflected in person2.

If Person were a structure, person1.name will be John, whereas person2.name will be Mike.
Structures in Swift are value types. Any change to a property of person1 would not be reflected into person2 and vice versa.

Question 2:

What is an optional in Swift and How it helps?

Answer:

An optional is used to let a variable of any type represent the lack of value. In Objective-C, the absence of value is available in reference types only, and it uses the nil special value. Value types, such as int or float, do not have such ability.

Swift extends the lack of value concept to both reference and value types with optionals. An optional variable can hold either a value or nil any time.

Question 3:

What is the difference between let and var in Swift?

Answer:

let kConstant = 10
var stringVariable : String

Here, we used the : string to explicitly declare that stringVariable will hold a string. In practice, it's rarely necessary — especially if the variable is given an initial value — as Swift will infer the type for you. It is a compile-time error trying to use a variable declared as a constant through let and later modifying that variable.

Question 4:

What is Completion Handler?

Answer:

Completion handlers are super convenient when our app is making an API call, and we need to do something when that task is done, like updating the UI to show the data from the API call. We’ll see completion handlers in Apple’s APIs like dataTaskWithRequest and they can be pretty handy in your own code.

The completion handler takes a chunk of code with 3 arguments:(NSData?, NSURLResponse?, NSError?) that returns nothing: Void. It’s a closure.

The completion handlers have to marked @escaping since they are executed some point after the enclosing function has been executed.

Question 5:

What is Singleton Pattern ?

Answer:

The Singleton design pattern ensures that only one instance exists for a given class and that there’s a global access point to that instance. It usually uses lazy loading to create the single instance when it’s needed the first time.

Question 6:

Closures  - value or reference types?

Answer:

Closures are reference types. If a closure is assigned to a variable and the variable is copied into another variable, a reference to the same closure and its capture list is also copied.

Question 7:

What are SQLite limits ?

Answer:

We need to define the relations between the tables. Define the schema of all the tables.

We have to manually write queries to fetch data.

We need to query results and then map those to models.

Queries are very fast.

Question 8:

What is CoreData ?

Answer:

Core data is an object graph manager which also has the ability to persist object graphs to the persistent store on a disk. An object graph is like a map of all the different model objects in a typical model view controller iOS application.

Question 9:

What are the execution states in iOS app?

Answer:

Not Running: The app is completely switched off, no code is being executed.

Inactive: The app is running in the foreground without receiving any events.

Active: The app is running in the foreground and receiving events.

Background: The app is executing code in the background.

Suspended: The app is in the background but is not executing any code.

Question 10:

What is AutoLayout?

Answer:

AutoLayout provides a flexible and powerful layout system that describes how views and the UI controls calculates the size and position in the hierarchy.

Auto Layout dynamically calculates the size and position of all the views in your view hierarchy, based on constraints placed on those views

10 comments:

  1. Thanks for Sharing this Valuable Information i like this i Can Share this with My Friend Circle.
    iOS Interview Questions and Answers

    ReplyDelete
  2. Great contribution by you for iOS Developers and Job Seekers.Keep the good work doing
    swift (iOS) interview questions and answers

    ReplyDelete
  3. Please continue this great work and I look forward to more of your awesome blog posts

    Data Science Corporate training in Tanzania

    ReplyDelete
  4. Thankyou for this wondrous post, I am glad I observed this website on yahoo.

    ReplyDelete
  5. I want to say thank you for all this valuable information. There are a ton of iPhone app developers out there, but how do you know which one is right for you and your project? Here are a few things to consider when choosing an iPhone app developer:

    -Do they have a good portfolio of apps? Take a look at their previous work to get an idea of their style and skills.
     
    -How responsive are they? When you contact them, do they get back to you promptly?

    -Do they seem excited about your project? You want to work with someone who is passionate about your app and will put in the extra effort to make it great.

    ReplyDelete

Post Top Ad