Javatpoint Logo
Javatpoint Logo

Top iOS Interview Questions

1) What are the different types of iOS Application States?

The different iOS application states are:

  • Not running: the app is considered to be in a Not Running state when it is not yet launched or terminated by the system or user.
  • Inactive: the app is in an inactive state when it is in the foreground but receiving events. In other words, we can say that it acts like a bridge state in which the app remains briefly when it transitions to a different state.
  • Active: it is a normal mode for the app when it is in the foreground state and receiving all the user events.
  • Background: the app transitions into the background state when the user taps on the home screen while using the application, or it requires some extra execution time. When the app is about to be suspended, then also transitions into this state for a small amount of time. In this state, the app remains in the background and executes the code.
  • Suspended: in this state, the app remains in the background and doesn't execute the code. The app is automatically moved to this state. In this state, the app remains in memory. However, the foreground apps are always given priority over suspended apps and can be purged any time without notice.

2) Which are the ways of achieving concurrency in iOS?

We can achieve Concurrency in iOS using the following three ways.

  1. Threads
  2. Dispatch Queues
  3. Operation Queues

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.

  1. application: didFinishLaunchingWithOptions:-> Bool: when the application is launched initially, this method is called. We can do any initial setup for the application in this method like firebase configuration, user navigation, etc. The storyboard is loaded at this point, but we can maintain the state restoration.
  2. applicationWillEnterForeground: this method is called after didFinishLaunchingWithOptions. It is also called when the application comes from background to foreground.
  3. applicationDidBecomeActive: this method is called after applicationWillEnterForeground. If we need to perform any particular task when the app comes into the foreground, like font update, etc., then we can place the code in this method.
  4. applicationWillResignActive: this method is notified when the application is about to become inactive. For example, the user receives a phone call; the user presses the home button, etc.).
  5. applicationDidEnterBackground: this method is notified when the application goes into a background state after become inactive.
  6. applicationWillTerminate: this method is called when the application is about to be finally terminated from memory. If we need to perform any final cleanups, then we can place the code in this method.

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.

  • The Model contains the things that are used to handle the data of the application. The models are used to parse the request and response with the server's API. Things like persistence, model objects, parsers, managers, and networking code reside here.
  • The View is treated as the face of the application. The object like UILabel and UITextField are the view objects that present the data on the screen. The view doesn't contain any domain-specific logic.
  • The controller is used as the mediator between the Model and the view via the delegation pattern. The controller doesn't need to know the concrete view it is working for. However, the controller contains the business logic to present the data that is parsed by the model and displayed by the view 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.

  • Model: It contains the application data. It is responsible for data parsing and data persistence.
  • View: It is responsible for displaying the model data on the screen, including the visual elements and controls. It is the subclass of UIView and highly reusable.
  • ViewModel: It contains the business logic that transforms the model data into the values and passes it to the view. In MVVM, all the business logic, including data manipulation, takes place at ViewModel.

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.

  1. View: The view consists of the View and View Controller. It contains only the view related code. It takes care of all the UI setup and events.
  2. Presenter: The presenter contains all the business logic of the application. It defines the user actions and updates the UI accordingly via the delegate methods. It is not UIKit dependent and, therefore, easily testable.
  3. Model: The model contains the application data. The networking calls, parser, extensions, manager, etc. take place here.

8) What are the different types of Queues available for GCD?

There are three types of a queue available for GCD.

  1. Main Queue: the main queue runs on the main thread, and it performs the serial execution of the thread.
  2. Global Queue: The Global queue is a concurrent queue and shared by the whole system. There are four global queues that operate on different priorities. The priorities are high, default, low, and background, where the background priority queue holds the minimum priority.
  3. Custom Queue: the developer creates the custom queues. They can be either concurrent or serial.

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.

  1. User Interactive: When we launch an application in iOS, to get a nice user experience, we need some tasks to be executed immediately. Such tasks are user interactive, which are to be executed for nice user experience. As a developer, we must use these tasks for UI Updates, event handling, and small workloads. The user-interactive tasks need to be executed on the main thread.
  2. User-Initiated: These tasks are initiated by the user from the user interface. These are asynchronous tasks that are to be used when the user waits in the application for immediate results, such as some API calls. The user-initiated tasks are executed in the high priority global queue.
  3. Utility: these are long-running tasks that run typically with a progress indicator. These types of threads are used for networking, computations, I/O, etc. These tasks are executed in the low priority global queue.

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.

  1. Instantiate the persistentContainer.
  2. Create the context object.
  3. Create an entity object.
  4. Create a new record object.
  5. Set values for the records for each key.

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.

  1. Content ViewController
  2. Container ViewController

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

  • Default
    When the button is added to the UIView initially, it remains in the default state until the user interacts with it. The state changes to other values as the user interacts with the button.
  • Highlighted
    When the user taps a button, it moves to the highlighted state.
  • focused
    The button enters into the focused state when it receives the focus of the user. We can change the appearance of the button in the focused state so that, it appears differently from the selected or focused state.
  • Selected
    This state does not affect the behavior or appearance of the button. However, this state is used for other controls like the UISegmentedControl class to use this state to change its appearance. We can get and set this value using isSelected property.
  • Disabled
    We might need to make the button disabled when we don't want the user to interact with the button. This state can be set and get using isEnabled property.

30) What are text field delegate methods?

There are the following TextField delegate methods.

SN Method Signature Description
1 func textFieldShouldBeginEditing(UITextField) -> Bool It asks the delegate if editing should begin the respective textfield.
2 func textFieldDidBeginEditing(UITextField) It tells the delegate that the editing is started in the textfield.
3 func textFieldShouldEndEditing(UITextField) -> Bool It asks the delegate to end the editing in the textfield.
4 func textFieldDidEndEditing(UITextField, reason: UITextField.DidEndEditingReason) It tells the delegate that the editing has been stopped for the specified textfield.
5 func textFieldDidEndEditing(UITextField) It is the overloaded methods which also does the same as the above.
6 func textField(UITextField, shouldChangeCharactersIn: NSRange, replacementString: String) -> Bool It asks the delegate that if the text field's current content should be changed.
7 func textFieldShouldClear(UITextField) -> Bool It asks the delegate if the text field's current content should be removed.

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.

  • Drawing and animation
    • By using views, we can draw into the rectangular area of the screen.
  • Layout and Sub view management
    • We can embed one or more subviews into the UIView. The appearance of the subviews can be managed by managing the appearance of the super view.
    • We can define the auto-layout rules to govern the size and positioning of the view hierarchy on different iOS devices.
  • Event Handling
    • A view can respond to the touch and another kind of event since it is the subclass of UIResponder.
    • We can add the gesture recognizers for the uiview, such as UITapGestureRecognizer.

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.

  1. It reports the number of rows and sections to be displayed in the tableview.
  2. It allocates the reusable cells for each row in the tableview.
  3. It provides the titles for headers and footers in the tableview sections.

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.

  • We can create the custom headers and footers for the sections in the tableview.
  • We can specify the custom heights for rows, headers, and footers.
  • Provide height estimates for the rows, headers, and footers.
  • We can define the method which can handle the row selections.

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.

1 func tableView(UITableView, numberOfRowsInSection: Int) -> Int This method returns the number of rows to be displayed in the section of the tableview.
2 func tableView(UITableView, cellForRowAt: IndexPath) -> UITableViewCell This method returns the object of a UITableViewCell, which shows the actual content of a particular row in the tableview. This method inserts the cell for a particular row in the 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.

1 func collectionView(UICollectionView, numberOfItemsInSection: Int) -> Int This method returns an integer representing the number of items in section to be displayed in the collectionview. It is the count of the array of data associated with the collectionview.
2 func collectionView(UICollectionView, cellForItemAt: IndexPath) -> UICollectionViewCell This method returns the instance of UICollectionViewCell which is configured to display the actual content. This method is not optional and to be defined if the view controller is conforming UICollectionViewDataSource protocol.

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?

SN Attribute Description
1 Image It represents an UIImage object to display. We can set the image from the storyboard or programmatically by using the image or animatedImages property of UIImageView class.
2 Highlighted It represents an UIImage object which is displayed when the imageview is highlighted. To set this attribute programmatically, we can use highlightedImage or highlightedAnimationImages property.
3 State This attribute is used to change the initial state of imageview to highlighted. Use the isHighlighted property to check whether the imageview is in highlighted state.


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.

  • If the image view's isOpaque property is true, the image's pixels are composited on top of the image view's background color, and the alpha property of the image view is ignored.
  • If the image view's isOpaque property is false, the alpha value of each pixel is multiplied by the image view's alpha value, with the resulting value becoming the actual transparency value for that pixel. If the image does not have an alpha channel, the alpha value of each pixel is assumed to be 1.0.

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.

  1. It updates the content of the views.
  2. It makes the views interactive so that it can respond to the events triggered by the user.
  3. It resizes the views and also manages the layout of the overall interface.

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.

  1. The most preferable way to specify custom views is by using a storyboard. We can specify the view in the storyboard and create the connection of the views to the respective ViewController class. We can also specify the relationships between different ViewControllers of the application in the storyboard itself. To load a view controller from the storyboard, we call the instantiateViewController(withIdentifier:) method of the UIStoryboard class. The storyboard object creates the viewcontroller object and returns it to the code.
  2. We can specify the views using a Nib file. However, the nib file facilitates us to specify the views for a single viewcontroller class but doesn't let us define relationships among different ViewControllers.
  3. We can specify the views for a ViewController using the loadView() method in which we create the view hierarchy programmatically and assign the root view of the hierarchy to the UIViewController view property.

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.

  • viewWillAppear(): This method is notified when the viewcontroller is about to be appeared. We prepare all of our views to appear on screen in this method.
  • viewDidAppear(): This method is notified once the view controller appeared. This method contains the code which is to be executed once the views are appeared on screen. Here, we can animate the views accordingly.
  • viewWillDisappear(): this method is notified when the view controller is about to be disappeared. We can place the code to save the changes or other state information in this method.
  • ViewDidDisappear(): this method is notified once the view controller is disappeared.

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.

  • It loads the tableview archived in the storyboard or the nib file. The TableViewController provides the tableview property to access the tableview in the storyboard.
  • It conforms to the UITableViewDelegate and UITableViewDatasource protocol by default. The subclass overrides the delegate and DataSource methods to provide the tableview implementation.
  • It automatically reloads the data for its tableview on the first appearance in the viewWillAppear(: ) method. It clears the selection every time the tableview is displayed.
  • It automatically toggles the edit mode of the table when the user taps an edit| done button in the navigation bar.
  • It automatically resizes the tableview on the appearance or disappearance of the onscreen keyboard.

57) What are the basic visible components of a TableViewController?

The following components are visible when we create a TableViewController.

  • TableView: The UITableViewController contains an in-built tableview. The tableview in the storyboard can be accessed by using tableView property in the TableViewController subclass. The tableview is an instance of the UITableView class.
  • TableViewCell: The tableview cell displays the actual content of the tableview controller. TableViewCell is an instance of the UITableViewCell class. The cell contains a content view of type UIView. We can add custom subviews to the content view in the tableview cell. However, there are two types of cells that can be displayed in the TableViewController: I.e., static cells to display static data and the prototype cell to customize a prototype of the data displayed in the cell.
  • NavigationController: The navigation controller is the one which controls the relationship among the ViewControllers in the storyboard. All the ViewControllers embed in the NavigationController contain the navigation bar where we can put title and bar button items. The navigation bar is the instance of the UINavigationBar class. We can show or hide the navigation bar for a tableview controller accordingly.

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?

SN Cocoa CocoaTouch
1 It provides app development environments for OS X. It provides app development environments for iOS
2 It includes Foundation and AppKit frameworks. It includes Foundation and UIKit frameworks
3 It is used to refer any class/object which is based on the Objective-C runtime and inherits from the root class It is used to refer the application development using any programmatic interface.

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.

  1. We can store user information like name, email address, age, or occupation in UserDefaults.
  2. We can store the navigation flags which can be checked in AppDelegate, and the user is navigated based upon the flags saved in UserDefaults.
  3. Application Settings like interface language, color theme, etc. can be stored in UserDefaults.
  4. We can store the user access token in the UserDefaults.

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.






You may also like:


Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA