IOS Interview Questions and Answers

Q.1.How could you setup Live Rendering ?
A.The attribute @IBDesignable lets Interface Builder perform live updates on a particular view.
Q.2.  What is the difference between Synchronous & Asynchronous task ?
A.Synchronous: waits until the task has completed Asynchronous: completes a task in background and can notify you when complete.
Q.3. What is made up of NSError object?
A.There are three parts of NSError object a domain, an error code, and a user info dictionary. The domain is a string that identifies what categories of errors this error is coming from.
Q.4.What is Enum ?
A.Enum is a type that basically contains a group of related values in same umbrella.


Q.5 Why don’t we use strong for enum property in Objective-C ?
A.Because enums aren’t objects, so we don’t specify strong or weak here.
Q.6 What is @synthesize in Objective-C ?
A.synthesize generates getter and setter methods for your property.
Q.7. What is @dynamic in Objective-C ? 
A.We use dynamic for subclasses of NSManagedObject. @dynamic tells the compiler that getter and setters are implemented somewhere else.

Q.8. Why do we use synchronized ?
A.synchronized guarantees that only one thread can be executing that code in the block at any given time.

Q.9. What is the difference strong, weaks, read only and copy ?
A.strong, weak, assign property attributes define how memory for that property will be managed.Strong means that the reference count will be increased and the reference to it will be maintained through the life of the objectWeak ( non-strong reference ), means that we are pointing to an object but not increasing its reference count. It’s often used when creating a parent child relationship. The parent has a strong reference to the child but the child only has a weak reference to the parent.Read only, we can set the property initially but then it can’t be changed.Copy, means that we’re copying the value of the object when it’s created. Also prevents its value from changing.

Q.10. What is Dynamic Dispatch ?
A.Dynamic Dispatch is the process of selecting which implementation
of a polymorphic operation that’s a method or a function to call at run time. This means, that when we wanna invoke our methods like object method. but Swift does not default to dynamic dispatch
Q.11. What is Singleton Pattern ?
A. 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.
Q.12. What is Facade Design Pattern ?
A. The Facade design pattern provides a single interface to a complex subsystem. Instead of exposing the user to a set of classes and their APIs, you only expose one simple unified API.
Q.13. What is JSON/PLIST limits ?
A. We create your objects and then serialized them to disk..
It’s great and very limited use cases.
We can’t obviously use complex queries to filter your results.
It’s very slow.
Each time we need something, we need to either serialize or deserialize it.
it’s not thread-safe.
Q.14. What is the Swift main advantage ?
A. To mention some of the main advantages of Swift:
Optional Types, which make applications crash-resistant
Built-in error handling
Much faster compared to other languages
Type-safe language
Supports pattern matching
Q.15. Explain generics in Swift ?
A. Generics create code that does not get specific about underlying data types. Don’t catch this article. Generics allow us to know what type it is going to contain. Generics also provides optimization for our code.
Q.16. What is ARC ?
A. ARC is a compile time feature that is Apple’s version of automated memory management. It stands for Automatic Reference Counting. This means that it only frees up memory for objects when there are zero strong references/ to them.
Q.17.What is iOS 11 SDK Features for Developers ?
A. New MapKit Markers
Configurable File Headers
Block Based UITableView Updates
MapKit Clustering
Closure Based KVO
Vector UIImage Support
New MapKit Display Type
Named colors in Asset Catalog
Password Autofill
Face landmarks, Barcode and Text Detection
Multitasking using the new floating Dock, slide-over apps, pinned apps, and the new App Switcher
Location Permission: A flashing blue status bar anytime an app is collecting your location data in the background. Updated locations permissions that always give the user the ability to choose only to share location while using the app.
Q.18.What is NSFetchRequest ?
A. NSFetchRequest is the class responsible for fetching from Core Data. Fetch requests are both powerful and flexible. You can use fetch requests to fetch a set of objects meeting the provided criteria, individual values and more.
Q.19.Explain NSPersistentContainer ?
A. The persistent container creates and returns a container, having loaded the store for the application to it. This property is optional since there are legitimate error conditions that could cause the creation of the store to fail.
Q.20.Explain NSFetchedResultsController ?
A. NSFetchedResultsController is a controller, but it’s not a view controller. It has no user interface. Its purpose is to make developers’ lives easier by abstracting away much of the code needed to synchronize a table view with a data source backed by Core Data.Set up an NSFetchedResultsController correctly, and your table will mimic its data source without you have to write more than a few lines of code.
Q.21.What is the difference CollectionViews & TableViews ?
A. TableViews display a list of items, in a single column, a vertical fashion, and limited to vertical scrolling only.
CollectionViews also display a list of items, however, they can have multiple columns and rows.
Q.22.What is Alamofire doing ?
A. Alamofire uses URL Loading System in the background, so it does integrate well with the Apple-provided mechanisms for all the network development. This means, It provides chainable request/response methods, JSON parameter and response serialization, authentication, and many other features. It has thread mechanics and execute requests on a background thread and call completion blocks on the main thread.
Q.23 REST, HTTP, JSON — What’s that?
A. HTTP is the application protocol, or set of rules, web sites use to transfer data from the web server to client. The client (your web browser or app) use to indicate the desired action:
GET: Used to retrieve data, such as a web page, but doesn’t alter any data on the server.
HEAD: Identical to GET but only sends back the headers and none of the actual data.
POST: Used to send data to the server, commonly used when filling a form and clicking submit.
PUT: Used to send data to the specific location provided.
DELETE: Deletes data from the specific location provided.
REST, or REpresentational State Transfer, is a set of rules for designing consistent, easy-to-use and maintainable web APIs.
JSON stands for JavaScript Object Notation; it provides a straightforward, human-readable and portable mechanism for transporting data between two systems. Apple supplies the JSONSerialization class to help convert your objects in memory to JSON and vice-versa.
Q.24.What problems does delegation solve?
A. Avoiding tight coupling of objects
Modifying behavior and appearance without the need to subclass objects
Allowing tasks to be handed off to any arbitrary object.
Q.25.What is the major purposes of Frameworks?
A. Frameworks have three major purposes:
Code encapsulation
Code modularity
Code reuse
Q.26. What is the difference between a delegate and an NSNotification?
A. Delegates and NSNotifications can be used to accomplish nearly the same functionality. However, delegates are one-to-one while NSNotifications are one-to-many.
Q.27.Explain SiriKit Limitations
A. SiriKit cannot use all app types
Not a substitute for a full app only an extension
Siri requires a consistent Internet connection to work
Siri service needs to communicate Apple Servers.
Q.28.Explain View Controller Lifecycle events order ?
A. There are a few different lifecycle event
– loadView
Creates the view that the controller manages. It’s only called when the view controller is created and only when done programatically.
– viewDidLoad
Called after the controller’s view is loaded into memory. It’s only called when the view is created.
– viewWillAppear
It’s called whenever the view is presented on the screen. In this step the view has bounds defined but the orientation is not applied.
– viewWillLayoutSubviews
Called to notify the view controller that its view is about to layout its subviews. This method is called every time the frame changes
– viewDidLayoutSubviews
Called to notify the view controller that its view has just laid out its subviews. Make additional changes here after the view lays out its subviews.
– viewDidAppear
Notifies the view controller that its view was added to a view hierarchy.
– viewWillDisappear
Before the transition to the next view controller happens and the origin view controller gets removed from screen, this method gets called.
– viewDidDisappear
After a view controller gets removed from the screen, this method gets called. You usually override this method to stop tasks that are should not run while a view controller is not on screen.
– viewWillTransition(to:with:)
When the interface orientation changes, UIKit calls this method on the window’s root view controller before the size changes are about to be made. The root view controller then notifies its child view controllers, propagating the message throughout the view controller hierarchy.
Q.29.What is interface?
A. The @interface in Objective-C has nothing to do with Java interfaces. It simply declares a public interface of a class, its public API.
Q.30. When and why do we use an object as opposed to a struct?
A. Structs are value types. Classes(Objects) are reference types.
Q.31.What is UIStackView?
A.UIStackView provides a way to layout a series of views horizontally or vertically. We can define how the contained views adjust themselves to the available space. Don’t miss this article.
Q.32.What are the states of an iOS App?
A. Non-running — The app is not running.
Inactive — The app is running in the foreground, but not receiving events. An iOS app can be placed into an inactive state, for example, when a call or SMS message is received.
Active — The app is running in the foreground, and receiving events.
Background — The app is running in the background, and executing code.
Suspended — The app is in the background, but no code is being executed.
Q.33.What is the difference between Array vs NSArray ?
A. Array can only hold one type of data, NSArray can hold different types of data. The array is value type, NSArray is immutable reference type.
Q.34.Explain Tuples
A. Tuples are a compound type in Swift, that means we can hold multiple values like a structure. Tuples hold very value types of data but we created data structures (like dictionaries).
Q.35.What is Cocoa and Cocoa Touch?
A. Cocoa :
1. Application development environments for OS X
2. Includes the Foundation and AppKit frameworks
3. Used to refer any class/object which is based on the Objective-C runtime & inherits from the root classCocoa Touch
1. Application development environments for iOS
2. Includes Foundation and UIKit frameworks
3. Used to refer the application development using any programmatic interface
Q.36.Which JSON framework is supported by iOS?
A. iOS supports SBJson framework.
SBJson is a JSON parser and generator for Objective-C.
It provides flexible APIs and additional control, making JSON handling easier.
Q.37.What is Swift and what is Objective-C?
A. Objective-C is the primary programming language you use to write software for OS X and iOS. It’s a superset of the C programming language and provides object-oriented capabilities and a dynamic runtime. Objective-C inherits the syntax, primitive types, and flow control statements of C and adds syntax for defining classes and methods. It also adds language-level support for object graph management and object literals while providing dynamic typing and binding, deferring many responsibilities until runtime.
Swift is a new programming language for iOS, OS X, watchOS, and tvOS apps that builds on the best of C and Objective-C, without the constraints of C compatibility. Swift adopts safe programming patterns and adds modern features to make programming easier, more flexible, and more fun. Swift feels familiar to Objective-C developers and is friendly to new programmers.
Q.38.Multitasking support is available from which version?
A. iOS 4.05. How many bytes we can send to apple push notification server.
Q.39.What Do You Mean By The Term “defer”?
A. The term “defer” is a keyword that provides a block of code that executes when the execution is leaving the current scope.
Q.40.Explain MVC
A.  Models — responsible for the domain data or a data access layer which manipulates the data, think of ‘Person’ or ‘PersonDataProvider’ classes.
Views — responsible for the presentation layer (GUI), for iOS environment think of everything starting with ‘UI’ prefix.
Controller/Presenter/ViewModel — the glue or the mediator between the Model and the View, in general responsible for altering the Model by reacting to the user’s actions performed on the View and updating the View with changes from the Model.
Q.41.Explain MVVM
A.  UIKit independent representation of your View and its state. The View Model invokes changes in the Model and updates itself with the updated Model, and since we have a binding between the View and the View Model, the first is updated accordingly.
Your view model will actually take in your model, and it can format the information that’s going to be displayed on your view.
There is a more known framework called RxSwift. It contains RxCocoa, which are reactive extensions for Cocoa and CocoaTouch.
Q.42.How many different annotations available in Objective-C ?

  • _Null_unspecified, which bridges to a Swift implicitly unwrapped optional. This is the default.
  • _Nonnull, the value won’t be nil it bridges to a regular reference.
  • _Nullable the value can be nil, it bridges to an optional.
  • _Null_resettable the value can never be nil, when read but you can set it to know to reset it. This is only apply property.