iOS Interview Questions and Answers
Here are a set of basic interview questions related to the iOS development and some of them are mostly asked in most of the interviews.
What is the difference between Synchronous task and Asynchronous task?
Ans.In a Synchronous task, the execution will be on hold until our synchronous task has been completed. In Asynchronous, the task will be completed in the background and we will be notified once the task is completed.
What is @synthesize in Objective C?
Ans.It generates setter methods as well as getter methods for the property.
Difference between strong and weak?
Ans.strong: Reference count will be increased and we own the object, it is in existence till be assign it to “nil“. weak: We are pointing to an object but the reference count is not increasing
what is Atomic and Non-Atomic in objective C?
Ans.atomic: Its a thread-safe property but it will cost us with performance, as its sure that only a single thread is accessing the property at a time. nonatomic: It is not threaded safe but the performance is good, and iOS uses it by default for all the properties.
Ans.ARC stands for automatic reference counting, it means the compiler automatically takes care of the memory management; the developer can now concentrate on the code rather than worrying about memory management.
What are functions?
Ans.With the help of functions we can create a set of statements to be performed one after the other; which in together completes a task. We can pass parameters to functions and based on the processing the functions can also return some values if required.
What are completion handlers?
Ans.If we have an application where the data is to be fetched from an API and then based on the data, some UI Updations to be done; completion handlers are one of the finest ways to do so. We initiate the task and once the task is completed; we get the call back to our handlers and then we can Update UI or make another API call as per the requirements.
Define design patterns in iOS Development?
Ans.Design patterns are solutions to common problems which we pass by in our day to day development life.
What is Singleton design patterns?
Ans. It ensures that only one instance exists for a given class and we have a global access point for the instance.
What is Observer Pattern?
Ans.In this patterns one object notifies the other object about the updations/state changes.
How can Observer pattern be achieved?
Ans.One is by Notifications and other is KVO (Key-Value Observing).
What is MVC Design pattern?
Ans.MVC stands for Model View and Controllers. Models are the data access layers which take care of the manipulation of data. Views are the presentation layers of the application; if we talk in terms of iOS say “UI“. Controllers are the middleman between View and Model. If any UI updations take place saying update the model, then its the controller which is doing the communication between the two.
What is VIPER Design Pattern in iOS development?
Ans.VIPER stands for View, Interactor, Presenter, Entity, and Router. View, here all the code related to UI is present or we can say the Application Interface. Presenter, it takes user response from Views and works accordingly, its the only class that communicates with all the other components. Interactor contains all the business logic of the application. Router, it listens to presenter which screen to present and executes the same. Entity, it consists of all the modal classes related to the application.
What is Grand Central Dispatch (GCD)?
Ans.GCD is a library that’s used to run tasks concurrently while managing threads in the background.
What is Dispatch Queues?
Ans.A dispatch queue is responsible for executing a task in FIFO concept (First in First Out order).
What is Serial Dispatch Queue?
Ans.one at a time will be executed.
What is Concurrent Dispatch Queue?
Ans.We can run as many as tasks required without worrying about the completion of any of the tasks.
What is Main Dispatch Queue?
Ans.This task runs on the main thread. (Always on Top Priority). As per new Apple Guidelines, all the UI updation should be done in main thread only.
What is difference NSOperation & NSOperationQueue?
Ans. Using NSOperation
gives a little extra advantage as compared to GCD, we can add dependency among various operations, re-use, cancel or suspend them as per our conditions.NSOperationQueue,
It allows a pool of threads so that we can execute NSOperations in parallel.
Multiple blocks can run at a time, with the help of NSBlockOperation.
All the best guys for the interview… we will add more questions… Much more to come stay tuned…