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.
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.
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.
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
Thanks for Sharing this Valuable Information i like this i Can Share this with My Friend Circle.
ReplyDeleteiOS Interview Questions and Answers
Great contribution by you for iOS Developers and Job Seekers.Keep the good work doing
ReplyDeleteswift (iOS) interview questions and answers
Please continue this great work and I look forward to more of your awesome blog posts
ReplyDeleteData Science Corporate training in Tanzania
This post is so interactive and informative.keep updating more information...
ReplyDeleteSwift Developer Course in Mumbai
Swift Developer Course in Kolkata
Swift Developer Course in Trivandrum
Swift Developer Course in Ahmedabad
Swift Developer Course in Cochin
ReplyDeleteSuch a great blog.Thanks for sharing useful information......
Swift Training In Bangalore
Swift Developer Training In Pune
Swift Developer Course In Gurgaon
Swift Developer Course In Hyderabad
Swift Developer Course In Delhi
Nice blog...Thanks for commenting…
ReplyDeleteImportance of IELTS
Benefits of IELTS exam
Perde Modelleri
ReplyDeletesms onay
mobil ödeme bozdurma
Nft Nasıl Alınır
ANKARA EVDEN EVE NAKLÄ°YAT
Trafik sigortası
dedektör
web sitesi kurma
aşk kitapları
en son çıkan perde modelleri
ReplyDeleteözel ambulans
nft nasıl alınır
yurtdışı kargo
lisans satın al
minecraft premium
en son çıkan perde modelleri
uc satın al
Thankyou for this wondrous post, I am glad I observed this website on yahoo.
ReplyDeleteI 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:
ReplyDelete-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.