iOS Interview Questions & Answers for Experienced [BEST & NEW]
iOS Interview Questions and Answers

iOS Interview Questions & Answers for Experienced [BEST & NEW]

Last updated on 18th Jun 2020, Blog, Interview Questions

About author

Akash (Sr Software Engineer - Mobile Development )

High level Domain Expert in TOP MNCs with 6+ Years of Experience. Also, Handled Around 18+ Projects and Shared his Knowledge by Writing these Blogs for us.

(5.0) | 17212 Ratings 1532

iOS technology is evolving in today’s world and how demanding it is in the upcoming years. In fact, according to one study, most of the companies and businesses have moved to iOS . Now, you cannot predict how huge the future is going to be for the people experienced in the related technologies. Hence, if you are looking for boosting up your profile and securing your future, iOS will help you in reaching the zenith of your career. Apart from this, you would also have a lot of opportunities as a fresher. Here are top IOS Interview questions and their answers are given just below to them. These sample questions are framed by experts. These IOS Interview Questions have been designed especially to get you acquainted with the nature of questions you may be asked during your interview for the subject of IOS app Development.

1. What are the characteristics of iOS?

Ans: 

Criteria Result
Type of operating system Apple proprietary based on Macintosh OS X
OS fragmentation Tightly integrated with Apple devices
Security Heightened security guaranteed

2. What is the benefit of writing tests in iOS apps?

Ans: 

  • Writing tests first gives us a clear perspective on the API design, by getting into the mindset of being a client of the API before it exists.
  • Good tests serve as great documentation of expected behavior.
  • It gives us confidence to constantly refactor our code because we know that if we break anything our tests fail.
  • If tests are hard to write it’s usually a sign architecture could be improved. Following RGR ( Red — Green — Refactor ) helps you make improvements early on.

3. How can you prevent iOS 8 app’s streaming video media from being captured by QuickTime Player on Yosemite during screen recording?

Ans: 

HTTP live streams that have their media encrypted will not be recorded by QuickTime Player on Yosemite while screen recording. These will blackout in the recording.

HTTP live streaming: It sends live and on‐demand audio and video to iPhone, iPad, Mac, Apple TV, and PC with HTTP live streaming (HLS) technology from Apple. Using the same protocol that powers the web, HLS lets us deploy the content using ordinary web servers and content delivery networks. HLS is designed for reliability and dynamically adapts to network conditions by optimizing playback for the available speed of wired and wireless connections.

4. How can you respond to state transitions on your app?

Ans: 

State transitions can be responded to state changes in an appropriate way by calling corresponding methods on the app’s delegate object.

For example:

  • applicationDidBecomeActive( ) method can be used to prepare to run as the foreground app.
  • applicationDidEnterBackground( ) method can be used to execute some code when the app is running in the background and may be suspended at any time.
  • applicationWillEnterForeground( ) method can be used to execute some code when your app is moving out of the background
  • applicationWillTerminate( ) method is called when your app is being terminated.

5: What is the difference between atomic and non-atomic properties? Which is the default for synthesized properties? When would you use one over the other?

Ans: 

  • Properties specified as atomic are guaranteed to always return a fully initialized object. This also happens to be the default state for synthesized properties.
  • While it’s a good practice to specify atomic to remove the potential for confusion, if you leave it off, your properties will still be atomic.
  • This guarantee of atomic properties comes at the cost of performance.
  • However, 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), setting it to non-atomic can boost performance.

6: Does Objective-C contain private methods?

Ans: 

 NO, there is nothing called a private method in Object-C programming. If a method is defined in .m only then it becomes protected. If in .h,it is public.

If you really want a private method then you need to add a local category/ unnamed category/ class extension in the class and add the method in the category and define it in the class.m.

7. How could you set up Live Rendering ?

Ans: 

The attribute @IBDesignable lets Interface Builder perform live updates on a particular view.

8. What is the difference between Synchronous & Asynchronous tasks ?

Ans: 

Synchronous: waits until the task has completed Asynchronous: completes a task in background and can notify you when complete

9. What Are B-Trees?

Ans: 

B-trees are search trees that provide an ordered key-value store with excellent performance characteristics. In principle, each node maintains a sorted array of its own elements, and another array for its children.

10. What is made up of NSError objects?

Ans: 

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.

11. What is the difference between an ‘App ID’ and a ‘Bundle ID’? What is each used for?

Ans: 

  • 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 strings, with a period (.) separating the two.
  • The Team ID is supplied by Apple and is unique to a specific development team, while a Bundle ID is supplied by the developer to match either the Bundle ID of a single app or a set of Bundle IDs of a group of apps.

Since most users consider the App ID as a string, they think it is interchangeable with the Bundle ID. Once the App ID is created in the Member Center, we can only use the App ID prefix that matches the Bundle ID of the application bundle.

The Bundle ID uniquely defines each app. It is specified in Xcode. A single Xcode project can have multiple targets and, therefore, outputs multiple apps. A common use case: an app having both lite/free and pro/full versions or branded multiple ways.

12. What Is Xcode?

Ans: 

  Xcode is Apple’s integrated development environment (IDE) that you use to design apps for Apple products. It provides various tools to manage your entire development workflow from creating your app, to testing, submitting and optimizing it to the App store.

13. How Multiple Line Comments Can Be Written In Swift?

Ans: 

 Multiple line comments can be written as forward-slash followed by an asterisk (/*) and end with an asterisk followed by a forward slash (*/).

14. What Are The Collection Types Available In Swift?

Ans: 

Multiple line comments can be written as forward-slash followed by an asterisk (/*) and end with an asterisk followed by a forward slash (*/).

15. What Are The Control Transfer Statements Used In Swift?

Ans: 

Control transfer statements used in Swift include:

  • Break
  • Continue
  • Fallthrough
  • Return

16. What Is The Characteristics Of Switch In Swift?

Ans: 

It supports any kind of data and not only Synchronizes it, but also checks for equality. The Switch statement must be exhaustive, which means that you have to cover all possible values for your variable.

17. What Is The Question Mark (?) In Swift?

Ans: 

The question mark (?) is used during the declaration of a property. It tells the compiler that this property is optional and whether the property may hold a value or not.

18. What Is The Use Of Double Question Marks (??)?

Ans: 

To provide a default value for a variable.

19. What Is The Difference Between Let And Var In Swift?

Ans: 

The let keyword is used to declare constants, while var is used for declaring variables.

20. Name the framework that is used to construct the application’s user interface for iOS.

Ans: 

  • The UIKit framework is used to develop the application’s user interface. The UIKit framework provides event handling, drawing model, windows, views, and controls, specifically designed for a touch-screen interface.
  • The UIKit framework (UIKit.framework) provides the crucial infrastructure needed to construct and manage iOS apps. This framework provides:
  • Window and view architecture to manage an app’s user interface
  • Event handling infrastructure to respond to the user input
  • An app model to drive the main run loop and interact with the system

In addition to the core app behaviors, UIKit provides support for the following features:

  • A view controller model to encapsulate the contents of the user interface
  • Support for handling touch and motion-based events
  • Support for a document model that includes iCloud integration
  • Graphics and windowing support, including support for external displays
  • Support for managing the app’s foreground and background execution
  • Printing support
  • Support for customizing the appearance of standard UIKit controls
  • Support for text and web content
  • Cut, copy, and paste support
  • Support for animating user-interface content
  • Integration with other apps on the system through URL schemes and framework interfaces
  • Accessibility support for disabled users
  • Support for the Apple Push Notification service
  • Local notification scheduling and delivery
  • PDF creation
  • Support for using custom input views that behave like the system keyboard
  • Support for creating custom text views that interact with the system keyboard
  • Support for sharing content through Email, Twitter, Facebook, and other services

    Subscribe For Free Demo

    21. What is plist?

    Ans: 

    Plist refers to Property lists that organize data into named values and lists of values using several object types. These types provide you the means to produce data that is meaningfully structured, transportable, storable, and accessible, but still as efficient as possible. Property lists are frequently used by applications running on both Mac OS X and iOS. The property-list programming interfaces for Cocoa and Core Foundation allow you to convert hierarchically structured combinations of these basic types of objects to and from standard XML. You can save the XML data to disk and later use it to reconstruct the original objects.

    The user defaults system, which you programmatically access through the NSUserDefaults class, uses property lists to store objects representing user preferences. This limitation would seem to exclude many kinds of objects like NSColor and NSFont objects, from the user default system. But if objects conform to the NSCoding protocol they can be archived to NSData objects, which are property list–compatible objects.

    22. What are the features added in iOS 9?

    Ans: 

    The following features are added in iOS 9 :

    • Intelligent search: It is an excellent mechanism to learn user habits and act on that information—open apps before we need them, make recommendations on places we might like, and guide us through our daily lives to make sure we’re where we need to be at the right time.
    • Siri: It is a personal assistant to the users that is able to create contextual reminders and search through photos and videos in new ways. Swiping right from the home screen brings up a new screen that houses ‘Siri Suggestions,’ putting favorite contacts and apps right on our fingertips, along with nearby restaurant and location information and important news.
    • Deeper search capabilities: It can show results such as sports scores, videos, and content from third-party apps, and we can even do simple conversions and calculations using the search tools on our iPhone or iPad.

    Performance improvements: The following built-in apps have been improved:

    • Notes including new checklists and sketching features
    • Maps now offering transit directions
    • Mail allowing for file attachments
    • New ‘News’ app that learns our interests and delivers relevant content we might like to read
    • Apple Pay being improved with the addition of store credit cards and loyalty cards
    • ‘Passbook’ being renamed to ‘Wallet’ in iOS 9

    San Francisco font

    • Wireless CarPlay support
    • Optional iCloud Drive app: It is a built-in two-factor authentication system with optional longer passwords for better security.

    23. How many ways can you create iOS UI?

    Ans: 

    •  Storyboard
    • XIB

    Programmatically:

    • VFL
    • Anchors
    • Constraint With Item
    • SwiftUI

    24. What is the Facade Design Pattern?

    Ans: 

    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.

    25. Describe managed object context and its function.

    Ans: 

    • A managed object context (represented by an instance of NSManagedObjectContext) is a temporary “scratchpad” in an application for a (presumably) related collection of objects. These objects collectively represent an internally consistent view of one or more persistent stores.
    • A single managed object instance exists in one and only one context, but multiple copies of an object can exist in different contexts.

    The key functions of managed object context include:

    • Life-cycle management: Here, the context provides validation, inverse relationship handling and undo/redo
    • Notifications refer to context posts notifications at various points that can be optionally monitored elsewhere in your application.
    • Concurrency is when the Core Data uses thread (or serialized queue) confinement to protect managed objects and managed object contexts.

    26. What is Enum or Enumerations In iOS?

    Ans: 

    According to Apple’s Swift documentation :

    We can keep track of how our app is being used by storing it in bytes as data at the moment. every enumeration denotes the different individual states of the application so we can use it to make a model of state and its internal processes.

    The Group of related values in the same umbrella is called enum. The case-less enum doesn’t allow the developer to create an instance of it.

    27. What Is @Synthesize in Objective-C?

    Ans: 

    Synthesize is used to create the getter and setter method for your property.

    28. What Widgets can not do ?

    Ans: 

    • No keyboard entry
    • Scroll views and multistep actions are discouraged

    29.  What are the limits of accessibility ?

    Ans: 

    We can not use Dynamic Text with accessibility features.

    30.  What is ARC and how is it different from AutoRelease?

    Ans: 

    Auto release is still used by ARC. ARC is used inside the scope, auto release is used outside the scope of the function.

    Course Curriculum

    Enroll in Advanced IOS Development Training By Certified Experts

    • Instructor-led Sessions
    • Real-life Case Studies
    • Assignments
    Explore Curriculum

    31. Explain differences between Foundation and CoreFoundation

    Ans: 

    The Foundation is a gathering of classes for running with numbers, strings, and collections. It also describes protocols, functions, data types, and constants. Core Foundation is a C-based alternative to Foundation. Foundation essentially is a Core Foundation. We have a free bridge with our NS counterpart.

    32. What’s accessibilityHint?

    accessibility Hint describes the results of interacting with a user interface element. A hint should be supplied only if the result of an interaction is not obvious from the element’s label.

    32. Explain placeholder constraint

    Ans: 

    This tells Interface Builder to go ahead and remove the constraints when we build and run this code. It allows the layout engine to figure out a base layout, and then we can modify that base layout at run time.

    33. Are you using Charles Proxy ? Why/why not ?

    Ans: 

    If I need a proxy server that includes both complete requests and responses and the HTTP headers then I am using Charles Proxy. With Charles Proxy, we can support binary protocols, rewriting and traffic throttling.

    34. What is the bounding box?

    Ans: 

     The bounding box is a term used in geometry; it refers to the smallest measure (area or volume) within which a given set of points.

    35. What Is A Guard Statement In Swift?

    Ans: 

      The guard statement evaluates a Boolean condition and proceeds with program execution if the evaluation is true.

    36. What Is Gcd? How Is It Used?

    Ans: 

    GCD is the most commonly used API to manage concurrent code and execute operations asynchronously at the UNIX level of the system. GCD provides and manages queues of tasks.

     37. What are the different ways to specify layout of elements in UIView?

    Ans: 

    Here are a few common ways to specify the layout of elements in UIView:

    • Using InterfaceBuilder, you can add an XIB file to your project, layout elements within it, and then load the XIB in your application code (either automatically, based on naming conventions, or manually). Also, using InterfaceBuilder you can create a storyboard for your application.
    • You can write your own code to use NSLayoutConstraints and have elements in a view arranged by Auto Layout.
    • You can create CGRects describing the exact coordinates for each element and pass them to UIView’s – (id)initWithFrame:(CGRect)frame method.

    38. What are Realm benefits ?

    Ans: 

    • An open-source database framework.
    • Implemented from scratch.
    • Zero copy object store.
    • Fast.

    39. What are SQLite limits ?

    Ans: 

    • We need to define the relations between the tables. Define the schema of all the tables.
    • We have to manually write queries to fetch data.
    • We need to query results and then map those to models.
    • Queries are very fast.

    40. What Is Core Data?

    Ans: 

    Core Data is an object graph manager, which also has the ability to persist object graphs to a persistent store, on a disk.

    41. What is Dynamic Dispatch?

    Ans: 

    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 methods. but Swift does not default to dynamic dispatch

    42. What is Nil Coalescing & Ternary Operator ?

    Ans: 

    It is an easy return of an unwrapped optional, or a default value. If we do not have value, we can set zero or default value.

    43. What makes React Native special for iOS?

    Ans: 

    • (Unlike PhoneGap) with React Native your application logic is written and runs in JavaScript, whereas your application UI is fully native; therefore you have none of the compromises typically associated with HTML5 UI.
    • Additionally (unlike Titanium), React introduces a novel, radical and highly functional approach to constructing user interfaces. In brief, the application UI is simply expressed as a function of the current application state

    44. What are the different ways to specify the layout of elements in UIView?

    Ans: 

    Here are a few common ways to specify the layout of elements in UIView :

    • Using InterfaceBuilder, we can add an XIB file to our project, layout elements within it, and then load XIB in our application code (either automatically, based on naming conventions, or manually). Also, using InterfaceBuilder, we can create a storyboard for our application.
    • We can write our own code to use NSLayoutConstraints and have elements in a view arranged by Auto Layout.
    • We can create CGRects describing the exact coordinates for each element and pass them to UIView’s (id)initWithFrame:(CGRect)frame method.

    To learn more about the layout of elements, check out this iOS Tutorial!

    45. What is the difference between atomic- and non-atomic properties? Which is default for synthesized properties? When would you use one over the other?

    Ans: 

      Properties specified as atomic are guaranteed to always return a fully initialized object. This also happens to be the default state for synthesized properties. While it is a good practice to specify atomic properties to remove the potential for confusion, if we leave it off, the properties will still be atomic.

    This guarantee of atomic properties comes at the cost of performance. However, if we have a property for which we 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 non-atomic can boost the performance.

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

    Ans: 

    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.

    47. What’s Code Coverage?

    Ans: 

    We can use Code Coverage to measure the value of our unit tests.

    48. How To Prioritize Usability in Design in iOS?

    Ans: 

    We have partitioned the design process to prioritize usability in 4 steps:

    • We have to design the UX like we are the user.
    • We have to remember that the users are people, not demographics.
    • We have to check each and every situation which can be useful while promoting the application.
    • We have to keep working on the utility of the app even after launch.

    49. What are Regular Expressions In iOS?

    Ans: 

    Regular Expressions are the special strings that help developers to search through to a string.

    50. What is Functions In iOS?

    Ans: 

    When We Are using the same task again and again in the code we should create a function and we can use it by the function name.

    51. What is Observer Pattern in iOS?

    Ans: 

    Observer pattern’s work is to show the changes in the other objects to one object. Cocoa implements the observer pattern in two ways: Notifications and Key-Value Observing (KVO).

    Course Curriculum

    Get Certification Oriented IOS Swift Course with In-Depth Practical

    Weekday / Weekend BatchesSee Batch Details

    52. What is Memento Pattern in iOS?

    Ans: 

    We can store our private data somewhere and we can restore it without disturbing encapsulation. Thus, private data remains private. There is Apple’s specialized implementation of the Memento pattern as part of State Restoration.

    53. What is TVMLKit in iOS?

    TVMLKit works as glue to stick between TVML, JavaScript, and our native tvOs application.

    54. What kind of JSONSerialization have ReadingOptions ?

    Ans: 

    • mutableContainers Specifies that arrays and dictionaries are created as variables objects, not constants.
    • mutableLeaves Specifies that leaf strings in the JSON object graph are created as instances of variable String.
    • allowFragments Specifies that the parser should allow top-level objects that are not an instance of Array or Dictionary.

    55. Explain subscripts ?

    Ans: 

    Classes, structures, and enumerations can define subscripts, which are shortcuts for accessing the member elements of a collection, list, or sequence.

    56. What is DispatchGroup ?

    Ans: 

    Dispatch Group allows for aggregate synchronization of work. We can use them to submit multiple different work items and track when they all complete, even though they might run on different queues. This behavior can be helpful when progress can’t be made until all of the specified tasks are complete.

    The most basic answer: If we need to wait on a couple of asynchronous or synchronous operations before proceeding, we can use DispatchGroup.

    57. Where do we use Dependency Injection ?

    Ans: 

    We use a storyboard or xib in our iOS app, then we created IBOutlets. IBOutlet is a property related to a view. These are injected into the view controller when it is instantiated, which is essentially a form of Dependency Injection.

    There are forms of dependency injection: constructor injection, property injection and method injection.

    58. Please explain types of notifications.

    Ans: 

    There are two types of notifications:

    Remote and Local. Remote notification requires connection to a server. Local notifications don’t require server connection. Local notifications happen on device.

    59. When is a good time for dependency injection in our projects?

    Ans: 

     There are a few guidelines that you can follow:

    • Rule 1: Is Testability important to us? If so, then it is essential to identify external dependencies within the class that you wish to test. Once dependencies can be injected we can easily replace real services for mock ones to make it easy to test.
    • Rules 2: Complex classes have complex dependencies, including application-level logic, or access to external resources such as the disk or the network. Most of the classes in your application will be complex, including almost any controller object and most model objects. The easiest way to get started is to pick a complex class in your application and look for places where you initialize other complex objects within that class.
    • Rules 3: If an object is creating instances of other objects that are shared dependencies within other objects then it is a good candidate for a dependency injection.

    60. What kind of order functions can we use on collection types ?

    Ans: 

    • map(_:): Returns an array of results after transforming each element in the sequence using the provided closure.
    • filter(_:): Returns an array of elements that satisfy the provided closure predicate.
    • reduce(_:_:): Returns a single value by combining each element in the sequence using the provided closure.
    • sorted(by:): Returns an array of the elements in the sequence sorted based on the provided closure predicate.

    61.  What is big-o notation ?

    Ans: 

    An algorithm is an impression method used to determine the working time for an input N size. The big-o notation grade is expressed by the highest value. And the big-o notation is finding the answer with the question of O(n). Here is a cheat sheet and swift algorithm club.

    For example:

    • For Loops big-o notation is O(N). Because For Loops work n times.
    • Variables (var number:Int = 4) big-o notation is O(1).

    62. What Is Dependency Management?

    Ans: 

    If we want to integrate an open source project, add a framework from a third party project, or even reuse code across our own projects, dependency management helps us to manage these relationships.

    63. What are UML Class Diagrams?

    Ans: 

    UML Class Diagram is a set of rules and notations for the specification of a software system, managed and created by the Object Management Group.

    64. Explain throw

    Ans: 

     We are telling the compiler that it can throw errors by using the throws keyword. Before we can throw an error, we need to make a list of all the possible errors you want to throw.

    65. What is Concurrency ?

    Ans: 

      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, multi threading, 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

    66. What are three triggers for a local notification ?

    Ans: 

    Location, Calendar, and Time Interval. A Location notification fires when the GPS on your phone is at a location or geographic region. Calendar trigger is based on calendar data broken into date components. Time Interval is a count of seconds until the timer goes off.

    67. Explain Selectors in ObjC

    Ans: 

    Selectors are Objective-C’s internal representation of a method name.

    68. What are Remote Notifications attacment’s limits ?

    Ans: 

    We can be sent with video or image with push notification. But the maximum payload is 4kb. If we want to send high quality attachment, we should use Notification Service Extension.

    69.Name four important data types found in Objective-C.

    Ans: 

    Four data types that you’ll definitely want your developer to be aware of are as follows :

    • NSString: Represents a string.
    • CGfloat: Represents a floating point value.
    • NSInteger: Represents an integer.
    • BOOL: Represents a boolean.

    70. How proficient are you in Objective-C and Swift? Can you briefly describe their differences?

    When Swift was first launched in 2014, it was aptly described as “Objective-C without the C.” By dropping the legacy conventions that come with a language built on C, Swift is faster, safer, easier to read, easier to maintain, and designed specifically for the modern world of consumer-facing apps. One of the most immediately visible differences is the fact that Objective-C lacks formal support for namespaces, which forces Objective-C code to use two- or three-letter prefixes to differentiate itself. Instead of simple names like “String,” “Dictionary,” and “Array,” Objective-C must use oddities like “NSString,” “NSDictionary,” and “NSArray.”

    Another major advantage is that Swift avoids exposing pointers and other “unsafe” accessors when referring to object instances. That said, Objective-C has been around since 1983, and there is a mountain of Objective-C code and resources available to the iOS developer. The best iOS developers tend to be pretty well versed in both, with an understanding that Swift is the future of iOS development.

    IOS Sample Resumes! Download & Edit, Get Noticed by Top Employers! Download

    71. What are UI elements and some common ways you can add them to your app?

    Ans: 

    Buttons, text fields, images, labels, and any other elements that are visible within the application are called UI elements. These elements may be interactive and comprise the user interface (hence the term “UI”) of an application. In iOS development, UI elements can be quickly added through Xcode’s interface builder, or coded from scratch and laid out using NSLayoutConstraints and Auto Layout. Alternatively, each element can also be positioned at exact coordinates using the UIView “(id)initWithFrame:(CGRect)frame” method.

    72. Explain the purpose of the reuseIdentifier in the UITableViewCell constructor:

    Ans: 

    (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier

    The reuseIdentifier tells UITableView which cells may be reused within the table, effectively grouping together rows in a UITableView that differ only in content but have similar layouts. This improves scroll performance by alleviating the need to create new views while scrolling. Instead the cell is reused whenever dequeueReusableCellWithIdentifier: is called.

    73. What are some common execution states in iOS?

    Ans: 

    The common execution states are as follows:

    • Not Running: The app is completely switched off, no code is being executed.
    • Inactive: The app is running in the foreground without receiving any events.
    • Active: The app is running in the foreground and receiving events.
    • Background: The app is executing code in the background.
    • Suspended: The app is in the background but is not executing any code.

    74. What is the purpose of managed object context (NSManagedObjectContext) in Objective-C and how does it work?

    Ans: 

    Managed object context exists for three reasons: life-cycle management, notifications, and concurrency. It allows the developer to fetch an object from a persistent store and make the necessary modifications before deciding whether to discard or commit these changes back to the persistent store. The managed object context tracks these changes and allows the developer to undo and redo changes.

    75. Determine the value of “x” in the Swift code below. Explain your answer.

    Ans: 

    • var a1 = [1, 2, 3, 4, 5]
    • var a2 = a1
    • a2.append(6)
    • var x = a1.count

    In Swift, arrays are implemented as structs, making them value types rather than reference types (i.e., classes). When a value type is assigned to a variable as an argument to a function or method, a copy is created and assigned or passed. As a result, the value of “x” or the count of array “a1” remains equal to 5 while the count of array “a2” is equal to 6, appending the integer “6” onto a copy of the array “a1.” The arrays appear in the box below.

    a1 = [1, 2, 3, 4, 5]

    a2 = [1, 2, 3, 4, 5, 6]

    76.  Find the bug in the Objective-C code below. Explain your answer.

    Ans: 

    77. Explain the difference between raw and associated values in Swift.

    Ans: 

    This question tests the developer’s understanding of enumeration in Swift. Enumeration provides a type-safe method of working with a group of related values. Raw values are compile time-set values directly assigned to every case within an enumeration, as in the example detailed below:

    78. You’ve just been alerted that your new app is prone to crashing. What do you do?

    Ans: 

    This classic interview question is designed to see how well your prospective programmer can solve problems. What you’re looking for is a general methodology for isolating a bug, and their ability to troubleshoot issues like sudden crashes or freezing. In general, when something goes wrong within an app, a standard approach might look something like this:

    • Determine the iOS version and make or model of the device.
    • Gather enough information to reproduce the issue.
    • Acquire device logs, if possible.
    • Once you have an idea as to the nature of the issue, acquire tooling or create a unit test and begin debugging.

    A great answer would include all of the above, with specific examples of debugging tools like Buglife or ViewMonitor, and a firm grasp of software debugging theory—knowledge on what to do with compile time errors, run-time errors, and logical errors. The one answer you don’t want to hear is the haphazard approach—visually scanning through hundreds of lines of code until the error is found. When it comes to debugging software, a methodical approach is must.

    79. Grand Central Dispatch (GCD)

    Ans: 

    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.

    80. Explain the difference between atomic and nonatomic synthesized properties?

    Ans: 

    Atomic and non-atomic refers to whether the setters/getters for a property will atomically read and write values to the property. When the atomic keyword is used on a property, any access to it will be “synchronized”. Therefore a call to the getter will be guaranteed to return a valid value, however this does come with a small performance penalty. Hence in some situations nonatomic is used to provide faster access to a property, but there is a chance of a race condition causing the property to be nil under rare circumstances (when a value is being set from another thread and the old value was released from memory but the new value hasn’t yet been fully assigned to the location in memory for the property).

    81. Explain the difference between copy and retain?

    Ans: 

    Retaining an object means the retain count increases by one. This means the instance of the object will be kept in memory until it’s retain count drops to zero. The property will store a reference to this instance and will share the same instance with anyone else who retained it too. Copy means the object will be cloned with duplicate values. It is not shared with anyone else.

    82. What is method swizzling in Objective C and why would you use it?

    Ans: 

    Method swizzling allows the implementation of an existing selector to be switched at runtime for a different implementation in a classes dispatch table. Swizzling allows you to write code that can be executed before and/or after the original method. For example perhaps to track the time method execution took, or to insert log statements

    • #import “UIViewController+Log.h”
    • @implementation UIViewController (Log)
    • + (void)load {
    • static dispatch_once_t once_token;
    • dispatch_once(&once_token, ^{
    • SEL viewWillAppearSelector = @selector(viewDidAppear:);
    • SEL viewWillAppearLoggerSelector = @selector(log_viewDidAppear:);
    • Method originalMethod = class_getInstanceMethod(self, viewWillAppearSelector);
    • Method extendedMethod = class_getInstanceMethod(self, viewWillAppearLoggerSelector);
    • method_exchangeImplementations(originalMethod, extendedMethod);
    • });
    • }
    • – (void) log_viewDidAppear:(BOOL)animated {
    • [self log_viewDidAppear:animated];
    • NSLog(@”viewDidAppear executed for %@”, [self class]);
    • }
    • @end

    83. What is a category and when is it used?

    Ans: 

    A category is a way of adding additional methods to a class without extending it. It is often used to add a collection of related methods. A common use case is to add additional methods to built in classes in the Cocoa frameworks. For example adding async download methods to the UIImage class.

    84. Explain what is defer ?

    Ans: 

    defer keyword which provides a block of code that will be executed in the case when execution is leaving the current scope.

    85. What is the difference between viewDidLoad and viewDidAppear? Which should you use to load data from a remote server to display in the view?

    Ans: 

    viewDidLoad is called when the view is loaded, whether from a Xib file, storyboard or programmatically created in loadView. viewDidAppear is called every time the view is presented on the device. Which to use depends on the use case for your data. If the data is fairly static and not likely to change then it can be loaded in viewDidLoad and cached. However if the data changes regularly then using viewDidAppear to load it is better. In both situations, the data should be loaded asynchronously on a background thread to avoid blocking the UI.

    86. What considerations do you need when writing a UITableViewController which shows images downloaded from a remote server?

    Ans: 

      This is a very common task in iOS and a good answer here can cover a whole host of knowledge. The important piece of information in the question is that the images are hosted remotely and they may take time to download, therefore when it asks for “considerations”, you should be talking about:

    Only download the image when the cell is scrolled into view, i.e. when cellForRowAtIndexPath is called.

    Downloading the image asynchronously on a background thread so as not to block the UI so the user can keep scrolling.

    When the image has downloaded for a cell we need to check if that cell is still in the view or whether it has been re-used by another piece of data. If it’s been re-used then we should discard the image, otherwise we need to switch back to the main thread to change the image on the cell.

    Other good answers will go on to talk about offline caching of the images, using placeholder images while the images are being downloaded.

    87. What is a protocol, and how do you define your own and when is it used?

    Ans: 

    A protocol is similar to an interface from Java. It defines a list of required and optional methods that a class must/can implement if it adopts the protocol. Any class can implement a protocol and other classes can then send messages to that class based on the protocol methods without it knowing the type of the class.

    88. What is KVC and KVO? Give an example of using KVC to set a value.

    Ans: 

    KVC stands for Key-Value Coding. It’s a mechanism by which an object’s properties can be accessed using string 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.

    • Let’s say there is a property name on a class:
    • @property (nonatomic, copy) NSString *name;
    • We can access it using KVC:
    • NSString *n = [object valueForKey:@”name”]
    • And we can modify it’s value by sending it the message:
    • [object setValue:@”Mary” forKey:@”name”]

    89. What are blocks and how are they used?

    Ans: 

      Blocks are a way of defining a single task or unit of behavior without having to write an entire Objective-C class. Under the covers Blocks are still Objective C objects. They are a language level feature that allow programming techniques like lambdas and closures to be supported in Objective-C. Creating a block is done using the ^ { } syntax:

    90. Explain MVVM

    Ans: 

    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.

    91. What is the Responder Chain?

    Ans: 

    When an event happens in a view, for example a touch event, the view will fire the event to a chain of UIResponder objects associated with the UIView. The first UIResponder is the UIView itself, if it does not handle the event then it continues up the chain to until the UIResponder handles the event. The chain will include UIViewControllers, parent UIViews and their associated UIViewControllers, if none of those handle the event then the UIWindow is asked if it can handle it and finally if that doesn’t handle the event then the UIApplicationDelegate is asked.

    92. What’s the difference between using a delegate and notification?

    Ans: 

    Both are used for sending values and messages to interested parties. A delegate is for one-to-one communication and is a pattern promoted by Apple. In delegation the class raising events will have a property for the delegate and will typically expect it to implement some protocol. The delegating class can then call the _delegate_s protocol methods.

    Notification allows a class to broadcast events across the entire application to any interested parties. The broadcasting class doesn’t need to know anything about the listeners for this event, therefore notification is very useful in helping to decouple components in an application.

    93. What’s your preference when writing UI’s? Xib files, Storyboards or programmatic UIView?

    Ans: 

    There’s no right or wrong answer to this, but it’s a great way of seeing if you understand the benefits and challenges with each approach. Here’s the common answers I hear:

    Storyboard and Xib are great for quickly producing UI’s that match a design spec. They are also really easy for product managers to visually see how far along a screen is Storyboards are also great at representing a flow through an application and allowing a high-level visualization of an entire application. Storyboard’s drawbacks are that in a team environment they are difficult to work on collaboratively because they’re a single file and merge become difficult to manage.

    Storyboards and Xib files can also suffer from duplication and become difficult to update. For example if all button’s need to look identical and suddenly need a color change, then it can be a long/difficult process to do this across storyboards and xibs. Programmatically constructing UIView’s can be verbose and tedious, but it can allow for greater control and also easier separation and sharing of code. They can also be more easily unit tested.

    Most developers will propose a combination of all 3 where it makes sense to share code, then reusable UIViews or Xib files.

    94. How would you securely store private user data offline on a device? What other security best practices should be taken?

    Ans: 

    Again there is no right answer to this, but it’s a great way to see how much a person has dug into iOS security. If you’re interviewing with a bank I’d almost definitely expect someone to know something about it, but all companies need to take security seriously, so here’s the ideal list of topics I’d expect to hear in an answer:

    If the data is extremely sensitive then it should never be stored offline on the device because all devices are crackable.

    The keychain is one option for storing data securely. However it’s encryption is based on the pin code of the device. User’s are not forced to set a pin, so in some situations the data may not even be encrypted. In addition the users pin code may be easily hacked.

    A better solution is to use something like SQLCipher which is a fully encrypted SQLite database. The encryption key can be enforced by the application and separate from the user’s pin code.

    Other security best practices are:

    • Only communicate with remote servers over SSL/HTTPS.
    • If possible implement certificate pinning in the application to prevent man-in-the-middle attacks on public WiFi.
    • Clear sensitive data out of memory by overwriting it.
    • Ensure all validation of data being submitted is also run on the server side.

    95. What is MVC and how is it implemented in iOS? What are some pitfalls you’ve experienced with it? Are there any alternatives to MVC?

    Ans: 

    MVC stands for Model, View, Controller. It is a design pattern that defines how to separate out logic when implementing user interfaces. In iOS, Apple provides UIView as a base class for all _View_s, UIViewController is provided to support the Controller which can listen to events in a View and update the View when data changes. The Model represents data in an application and can be implemented using any NSObject, including data collections like NSArray and NSDictionary.

    96. Explain NSPersistentContainer

    Ans: 

    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.

    97. What is AutoLayout? What does it mean when a constraint is “broken” by iOS?

    Ans: 

    AutoLayout is a way of laying out UIViews using a set of constraints that specify the location and size based on other views or based on explicit values. AutoLayout makes it easier to design screens that resize and layout out their components better based on the size and orientation of a screen. _Constraint_s include:

    • setting the horizontal/vertical distance between 2 views
    • setting the height/width to be a ratio relative to a different view
    • a width/height/spacing can be an explicit static value

    Sometimes constraints conflict with each other. For example imagine a UIView which has 2 height constraints: one says make the UIView 200px high, and the second says make the height twice the height of a button. If the iOS runtime can not satisfy both of these constraints then it has to pick only one. The other is then reported as being “broken” by iOS.

    98. What is the difference between retain & assign?

    Ans: 

    • Assign creates a reference from one object to another without increasing the source’s retain count.
    • if (_variable != object)
    • {
    • [_variable release];
    • _variable = nil;
    • _variable = object;
    • }
    • Retain creates a reference from one object to another and increases the retain count of the source object.
    • if (_variable != object)
    • {
    • [_variable release];
    • _variable = nil;
    • _variable = [object retain];
    • }

    99. What JSON framework is supported by iOS (iPhone OS)?

    Ans: 

    The SBJson framework is supported by iOS. It is a JSON parser and generator for Objective-C (Objective-C is the primary programming language you use when writing software for OS X and iOS. It’s a superset of the C programming language and provides object-oriented capabilities and a dynamic runtime).

    SBJson provides flexible APIs and additional control that makes JSON handling easy.

    Are you looking training with Right Jobs?

    Contact Us
    Get Training Quote for Free