Top iOS Interview Questions1) What are the different types of iOS Application States?The different iOS application states are:
2) Which are the ways of achieving concurrency in iOS?We can achieve Concurrency in iOS using the following three ways.
3) What are the different iOS app lifecycle methods?There are the following iOS app lifecycle methods which are called when the app transitions from one state to another.
4) Explain Model View Controller Architecture to develop iOS applications?MVC is the commonly used beginner-level software architecture design pattern made with the following objects.
5) What are the problems with MVC Architecture?The most common problem with the MVC is data formatting. In MVC, the model contains the application's data. While developing iOS applications, there are the requirements that the data needs to be formatted before presenting it to the user. In MVC, the problem is where the formatting takes place. The model is not required to be told about the data being displayed to the user. The model doesn't need to understand the data displayed to the user; therefore, the only object that can be used to place the formatting code is Controller since the controller is already heavy after having so much business logic, including the data source and delegate method. Hence, the controller becomes so much heavy in MVC because all the data manipulation tasks also take place at the Controller 6) What is Model-View-ViewModel Architecture?MVVM (Model View View-Model) is an iOS architectural design pattern in which we separate objects into three main components.
7) What is Model-View-Presenter Architecture?Model View Presenter (MVP) is a design pattern that separates the objects into three main components: Model, View, and Presenter. Now, the View Controller is considered as View, and the presenter contains all the business logic of the application.
8) What are the different types of Queues available for GCD?There are three types of a queue available for GCD.
9) What are GCD Concepts?GCD stands for Grand-Central-Dispatch, which is an API that is used to execute the closures on the worker pools. Here, the execution is done in the First-In-First-Out (FIFO) order. The tasks that are to be executed by the CPU are submitted to the dispatch queue in the form of blocks by the application. This block is executed on a thread pool that is provided by the system. All the tasks in the dispatch queue are executed either sequentially or concurrently. However, the dispatch queue always maintains the FIFO order of the tasks. 10) What are QoS Classes?When the tasks are sent to global queues, we specify a quality-of-service class property. The QoS classes determine the priority of the tasks and then allow GCD to execute them. 11) What are the different types of categories of QoS classes?There are the following categories of QoS classes present in the system.
12) How to parse the JSON Response using JSONDecoder?To parse the response in Alamofire API request, we will use JSONDecoder, which is an object that decodes instances of a data type from JSON objects. The decode method of JSONDecoder is used to decode the JSON response. It returns the value of the type we specify, decoded from a JSON object. The syntax is given below. 13) What are UserDefaults?UserDefaults are used to save small pieces of data in the application. It can be used to save the application's settings, some flags, or user tokens. The UserDefaults is a property list file in the application package. It stores data as the key-value pairs (dictionary); therefore, userdefaults is considered as the Key-Value-Store (KVS). The UserDefaults is the instance of the UserDefaults class provided by Apple. It was formerly known as NSUserDefaults. 14) How to save data in UserDefaults?To save the data in the UserDefaults, first, we need to get the reference to the UserDefaults by using the standard property. The following code can be used to save a string in the UserDefaults. 15) How to remove data from UserDefaults?To remove any value from the UserDefaults, the removeObject() method is used. Here, we want to remove the value for key userToken, we can write the following code. 16) What is CoreData?CoreData is the framework provided by Apple to save, track, filter, and modify the data within the iOS applications. It is not the database, but it uses SQLite as it's persistent store. It is used to manage the model layer object in our application. It manages the object graphs, tracks the changes in the data, and modifies the data on the user interactions. 17) How to add data in the CoreData model?To add records to the model, we need to follow the following steps.
18) What is Managed Object Model?Managed Object Model can be defined as the set of objects that are used to form a blueprint describing the managed object we use in our application. In other words, the Managed object model can be seen as a schema that the CoreData uses. It is an instance of NSManagedObjectModel class. However, the Managed Object Model includes the application's entities, the properties, and the relationship between them. 19) What is Abstract Entity?An entity is abstract if we do not create any instances of that entity. We make an entity abstract if we have a number of entities that all inherit from a common entity that should not itself be instantiated. For example, in the Student entity, we can define Person as an abstract entity and specify that only concrete subentities (Student) can be instantiated. 20) What is Persistent Object Coordinator?A persistent store coordinator includes the persistent object stores and a managed object model and presents a facade to managed object contexts such that a group of persistent stores appears as a single aggregate store. It is the object of NSPersistentStoreCoordinator. It contains the reference to a NSManagedObjectModel object which defines the entities in the store. it is the central object in the Core Data stack. 21) How to add Pull-to-Refresh functionality in an iOS app?Apple provides us the UIRefreshControl class, which simplifies adding the pull to refresh. The First thing we need to do is instantiate the UIRefreshControl class. Here, we need to add this refresh control to our view. We can assign the refreshControl property of the view to this instance. However, we must notice that, before iOS 10, there was not a property like refreshControl. We had to add it as a sub view to the view. 22) What is a View Controller in iOS development?In iOS development, the view controllers are the foundation of the Application's internal structure. The View Controller is the parent of all the views present on a storyboard. Each application has at least one ViewController. It facilitates the transition between various parts of the user interface. 23) Which class is parent class of all the View Controllers?The UIViewController is the parent class of all the ViewControllers. It defines all the methods and properties for managing our views. This class also manages the events and transitions from one view controller to another. It also coordinates between the different parts of the application. 24) What are the types of View Controllers in iOS development?There are two types of View Controllers in iOS.
25) What is Content ViewController?Content ViewControllers are the main type of View Controllers that we create. The Content View Controllers holds the content of the Application screen. In other words, we can say that the Content View Controller manages the discrete piece of the application content. The Content ViewController manages all the Views itself. 26) What is Container ViewController?Container ViewController is different from content ViewController in the sense that it acts as a parent View Controller, which collects information from the child view controllers. The task of the container view controller is to present the collected information to facilitate the navigation to the child view controllers. The container ViewController only manages the RootView, which incorporates one or more Child ViewControllers. 27) What are Segues?Segues are used to make the transitions between two screens in the storyboard. We can set the type of transition like the model or push on the segue. In simple words, the segue is like an arrow defined on an object like a button or ViewController so that any user event on the object leads to the transition defined by the segue. 28) What is storyboard in iOS development?The storyboard is a visual representation of the user interface of an iOS app. It can be defined as the sequence of screens, each of which represents the ViewController and the Views. The transitions between two storyboard screens need a segue object, which represents a transition between two ViewControllers. 29) What are different types of states of a button in an iOS app?Buttons can have five states
30) What are text field delegate methods?There are the following TextField delegate methods.
31) What is the parent class to implement text fields in iOS app?The following class is the parent class to implement text fields in iOS app. 32) What is Segment Control in iOS?Segment control can be defined as the horizontal control, which controls multiple segments where a discrete button controls each segment. A segment control can be used to display multiple views within a single view controller, where each view can be displayed by using a discrete button. 33) What is a XIB file?XIB stands for an XML interface builder. The interface builder allows us to develop graphical user interfaces with the help of cocoa and carbon. XIB files are loaded at the runtime to provide the user interface for the application. The XIB files are stored as NIB or XIB files, which represent UIView. 34) What is UIView in CocoaTouch?UIView can be defined as an object by using which we can create and manage the rectangular area on the screen. We can have any number of views inside a view to create a hierarchical structure of the UIViews. The UIView is managed by using the methods and properties defined in the UIView class that inherits UIKit. 35) What are the activities of UIView in iOS Applications?There are several activities that are performed by the views in the iOS application.
36) Whay we need to use TableView in iOS app?In iOS applications, whenever we need to display the single column containing vertically scrolling content, we use tableview. The tableview can display multiple records (divided into rows), which can be scrolled vertically if needed. Each row of the tableview presents each record of the data source. For example, in the contact app, we display each contact name in the separate row of the tableview, and we get the details related to the contact on the click to that row. 37) What is the parent class to implement TableView in iOS app?The following class is the parent class to implement tableview. 38) What are the main tasks of a tableview DataSource object?To maintain the data to be displayed by the tableview, we need to maintain a DataSource object that implements the UITableViewDataSource protocol. The datasource object manages the tableview data. The datasource object performs the following main tasks.
39) What are the main tasks of a tableview delegate object?The tableview delegate methods are defined to add the following features to the tableview.
40) What are the tableview DataSource methods that are necessary to be implemented in order to use tableview in iOS app?The following two DataSource methods are necessary to implement for using tableview.
41) how to maintain the height of tableview dynamically?To provide the height of tableview according to the content height, return UITableView.automaticDimension in heightForRowAt delegate method. Consider the following syntax. 42) What is the use of dequeueReusableCell(withIdentifier: ) in creating tableview cell?It is used to create reusable tableview cell which can be returned from cellForRowAt(:) tableView delegate method. The table view cells are created in a way that a particular cell can be reused at a certain indexpath. For example, if an iOS device screen is able to contain 4 table view cell at once and there are 8 total tableview cell, then the tableview starts reusing the top 4 cells at bottom indexes as well. Consider the following syntax to use dequeueReusableCell(withIdentifier: ) method. 43) What is a CollectionView in iOS applications?CollectionView is an object that presents the ordered collection of data items in the customizable layouts. It shows the data in the form of a grid layout. A collectionview is an instance of the UICollectionView class, which inherits the UIScrollView. 44) What are supplementary views?A CollectionView can also present the data using the supplementary views as well. The supplementary views are the section headers and footers that are configured using the UICollectionViewDelegate methods. Support for supplementary views can be defined by the collection view layout object. The collection view layout object also defines the placement of those views. 45) What are the main tasks of CollectionView Delegate and DataSource objects?The collection view DataSource object is responsible for providing the data that is required by the collectionview. It is like the collectionview application's data model. It passes the data to the collectionview that is to be displayed. On the other hand, CollectionView Delegate object handles the selection, deselection, highlighting the items in the collectionview. 46) What are the required CollectionView DataSource methods?The following methods are required to implement for using collectionview.
47) what is the parent class to use Scroll View in iOS application?The following class is the parent class of Scroll View. 48) What is the interface builder attributes for UIImageView?
49) How to manage the image transparency in iOS application?If the size of the image is smaller than the imageview, than any transparency in the image leads to the background display through since the image is composited onto the imageview background and then onto the rest of the available image.
50) How to add touch events to the image view?By default, the imageview doesn't respond to the events. However, we can set the imageview's isUserInteractionEnabled property to true to make the user interaction enabled for the imageview. We can configure the tap gestures for the imageview using UITapGestureRecognizer. 51) What is MapView in iOS?The MapView is the object that can display an embeddable map interface in the iOS applications. It is similar to the one that is provided by the Maps applications. It is an instance of the MKMapView class, which inherits the UIView class. 52) What are the main responsibilities of a UIViewController ?UIViewController inherits the UIResponder class, which enables the user interactions with views. There are the following responsibilities of UIViewController.
53) How many ways are there to create UIViews in iOS?There are the following ways that can be used to specify the views in the iOS applications.
54) What are the methods that are notified on View State changes?The following methods are notified on the change in the appearance of the viewcontroller.
55) How the memory management works in UIViewController?The ViewControlles provides built-in support to release the unused memory by the iOS application, which also stops the memory leak in the application if any. The UIViewController class provides a lifecycle method didRecieveMemoryWarning(), which is notified on the low-level memory condition. 56) What are the advantages of using UITableViewController instead of tableView?The UITableViewController provides the following benefits.
57) What are the basic visible components of a TableViewController?The following components are visible when we create a TableViewController.
58) What are the different Components of a UICollectionViewController?Different components of a UICollectionViewController are given as below. CollectionView: The Collection View Controller provides an in-built collection view with a collection view cell. This collectionview can be accessed by using collectionView property in the UICollectionViewController subclass. It is an instance of the UICollectionView class which inherits UIView. CollectionViewCell: The Collection View Cell displays the actual content of the Collection View Controller. It contains a content view of type UIView to which we can add the custom subviews. It is an instance of the UICollectionViewCell class. NavigationBar: Navigation Bar is shown on the top of the ViewControllers that are embedded in the navigation controllers. It contains title and bar button items. It is an instance of the UINavigationBar class. 59) How can we provide bottom navigation bar in iOS?For this purpose, Tab Bar Controllers are used. It is a container view controller that manages an array of view controllers in a radio-style selection interface so that the user can interact with the interface to determine the view controller to display. It is the instance of UITabBarController, which inherits UIViewController. In the tab bar interface, a tab bar is displayed at the bottom of the screen with multiple tab bar button items for selecting between different modes of the application 60) What is Tab Bar in iOS?A TabBar is a control that is used to display and configure one or more bar button items in a tab bar for selecting between different subtasks, views, or modes in the iOS application. The TabBar is used in association with the TabBarController to present the list of tabs in the application. However, we can use the tab bar as stand-alone control in the application. The Tab Bar is the instance of the UITabBar class, which inherits UIView. The tab bar always appears across the bottom edge of the screen. A UITabBar object contains one or more UITabBarItem objects. However, we can customize the appearance of the Tab Bar by changing its background color, image, or tint color according to the interface. When we use the UITabBarController object, we are provided with an in-built UITabBar object that can be customized using interface builder or programmatically. 61) What is More Navigation Controller?The TabBar associated with the tab bar controller has a limited space to show the custom tab bar items. However, if we add more than four items to a tab bar, then the tab bar contains only the first four items along with the more option to display the additional items. The more item presents a standard interface to select the additional items. 62) How can we navigate between two view controllers in iOS?There are two ways to navigate between two view controllers. 1. Using Segue: Segues are used to make the transitions between two screens in the storyboard. We can set the type of transition like the model or push on the segue. In simple words, the segue is like an arrow defined on an object like a button or ViewController so that any user event on the object leads to the transition defined by the segue. Sometimes, we may need to pass the data between the ViewControllers. It can be done by using prepareForSegue method, which is invoked on the View Controller when the segue is triggered. The segue can either be performed on the tap of the object on which the segue is defined or programmatically by using performSegue(withIdentifier: String) method on ViewController. 2. Using Navigation Controller We can embed the view controller in navigation controller. The Navigation Controller manages one or more child view controllers in the navigation interface. Even though one or more child view controllers are managed into navigation stack, only one view controller appears on-screen at an instance. Selecting an item in the view controller pushes a new view controller on the screen. This process is animated and therefore hides the previous view controller. A Navigation Controller manages the View Controllers in the ordered array where the first item is considered as the root view controller and also the bottom of the navigation stack. The last item in the array is the topmost view controller, which is currently being displayed. We can push or pop View Controllers into the stack using the methods of UINavigationController class. We can use the following method to push a view controller into the navigation stack. 63) Why StackViews are useful in developing iOS applications?StackView is useful to manage a UI which requires views to be added or removed at runtime based on a certain user event. It simplifies the task to layout a series of views (horizontally and vertically) by managing the spacing among the views. We won't need to change, add, or remove constraints for the inner views at runtime. We only need to provide constraints to stackview. 64) What is the difference between Cocoa and CocoaTouch?
65) What are the use cases of using UserDefaults in iOS application?The UserDefaults are mainly used to store simple pieces of data. However, if we need to store multiple objects of the same type, it's better to use an actual database, like CoreData or SQLite. Database design is an important aspect of the architecture of your app. UserDefaults are mainly used in the following scenario.
66) Why do people jail break the iPhones?Jailbreaking enhances the possibility of installing software that can unofficially unlock carrier-locked iPhones. The unlocked carrier-locked iPhones can be used with other carriers as well. Jailbreaking also allows the installation of pirated software on iOS. However, such applications are not available through the App Store. Consumer software is restricted to be installed using App Store, such software can be installed via jailbreaking. |