Sunday, 28 July 2019

IOS DEVELOPER INTERVIEW QUETIONS

1. Explain the different types of iOS Application States.

The different iOS application states are:

  • Not running state: when the app has not been launched or was running but was terminated by the system.
  • Inactive state: when the app is running in the foreground but is currently not receiving events. An app stays in this state briefly as it transitions to a different state. The only time it stays inactive is when the user locks the screen or the system prompts the user to respond to some event such as a phone call or SMS message.
  • Active state: when the app is running in the foreground and is receiving events. This is the normal mode for foreground apps.
  • Background state: when the app is in the background and executing code. Most apps enter this state briefly on their way to being suspended. However, an app that requests extra execution time can remain in this state for some time. Also, an app being launched directly into the background enters this state instead of the inactive state.
Suspended state: A suspended app remains in memory but does not execute any code. When a low-memory condition occurs, the system may purge suspended apps without notice to make more space for the foreground app.

2. What is autorealease pool?

Every time -autorelease is sent to an object, it is added to the inner-most autorelease pool. When the pool is drained, it simply sends -release to all the objects in the pool.
Autorelease pools are a convenience that allows you to defer sending -release until “later”. That “later” can happen in several places, but the most common in Cocoa GUI apps is at the end of the current run loop cycle.


3. Differentiate ‘app ID’ from ‘bundle ID’. Explain why they are used.
An App ID is a two-part string used to identify one or more apps from a single development team. The string consists of a Team ID and a bundle ID search string, with a period (.) separating the two parts. The Team ID is supplied by Apple and is unique to a specific development team, while the bundle ID search string is supplied by the developer to match either the bundle ID of a single app or a set of bundle IDs for a group of apps.
The bundle ID defines each App and is specified in Xcode. A single Xcode project can have multiple targets and therefore output multiple apps. A common use case is an app that has both lite/free and pro/full versions or is branded multiple ways.

 4.How could you setup Live Rendering? 

The attribute 
@IBDesignable lets Interface Builder perform live updates on a particular view. IBDesignable requires Init frame to be defined as well in UIView class.



       5.What is Dynamic Dispatch? 

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

     6.What’s the difference between the frame and the bounds? 


The bounds of a UIView is the rectangle, expressed as a location (x,y) and size (width,height) relative to its own coordinate system (0,0). 
The frame of a UIView is the rectangle, expressed as a location (x,y) and size (width,height) relative to the superview it is contained within.


     7.What is Singleton Pattern ? 

    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.

    9. What is Observer Pattern? 
In the Observer pattern, one object notifies other objects of any state changes.
    Cocoa implements the observer pattern in two ways: Notifications and Key-Value Observing (KVO).

    10.Explain MVC
·         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.
    11. - What is the Swift main advantage ? 
To mention some of the main advantages of Swift:
·         Optional Types, which make applications crash-resistant
·         Built-in error handling
·         Closures
·         Much faster compared to other languages
·         Type-safe language
·         Supports pattern matching
1    12- Explain generics in Swift ? 
    Generics create code that does not get specific about underlying data types. Generics allow us to know what type it is going to contain. Generics also provides optimization for our code.
     13- Explain lazy in Swift ? 
  An initial value of the lazy stored properties is calculated only when the   property is called for the first time. There are situations when         the lazyproperties come very handy to developers.

1    14- How to pass a variable as a reference ? 
    We need to mention that there are two types of variables: reference and value types. The difference between these two types is that by passing value type, the variable will create a copy of its data, and the reference type variable will just point to the original data in the memory.
1 15- How to pass data between view controllers?
       There are 3 ways to pass data between view controllers.
1.    Segue, in prepareForSegue method (Forward)
2.    Delegate (Backward)
3.    Setting variable directly (Forward)
16. What is Concurrency ?
Concurrency is dividing up the execution paths of your program so that they are possibly running at the same time. The common terminology: process, thread, multithreading, and others. Terminology;
·         Process, An instance of an executing app
·         Thread, Path of execution for code
·         Multithreading, Multiple threads or multiple paths of execution running at the same time.
·         Concurrency, Execute multiple tasks at the same time in a scalable manner.
·         Queues, Queues are lightweight data structures that manage objects in the order of First-in, First-out (FIFO).
·         Synchronous vs Asynchronous tasks
117- Grand Central Dispatch (GCD)
GCD is a library that provides a low-level and object-based API to run tasks concurrently while managing threads behind the scenes. Terminology;
·         Dispatch Queues, A dispatch queue is responsible for executing a task in the first-in, first-out order.
·         Serial Dispatch Queue A serial dispatch queue runs tasks one at a time.
·         Concurrent Dispatch Queue A concurrent dispatch queue runs as many tasks as it can without waiting for the started tasks to finish.
·         Main Dispatch Queue A globally available serial queue that executes tasks on the application’s main thread.

18- KVC — KVO
KVC
 adds stands for Key-Value Coding. It’s a mechanism by which an object’s properties can be accessed using string’s at runtime rather than having to statically know the property names at development time.
   KVO stands for Key-Value Observing and allows a controller or class to observe changes to a property value. In KVO, an object can ask to be notified of any changes to a specific property, whenever that property changes value, the observer is automatically notified.

1   19- Explain Guard statement
There are three big benefits to guard statement.
    One is avoiding the pyramid of doom, as others have mentioned — lots of annoying if let statements nested inside each other moving further and further to the right. The second benefit is providing an early exit out of the function using break or using return.

2        20. Which JSON framework is supported by iOS ?
            
       SBJson framework is supported by iOS. It is a JSON parser and generator for Objective-  C. SBJson provides flexible APIs and additional control that makes JSONhandling easier.


  21.What is the difference between atomic and nonatomic properties? Which is the default for synthesized properties?
     Properties specified as atomic always return a fully initialized object. This also happens to be the default state for synthesized properties. But, if you have a property for which you know that retrieving an uninitialized value is not a risk (e.g. if all access to the property is already synchronized via other means), then setting it to nonatomic can give you better performance than atomic.





   












No comments:

Post a Comment