Categories

Top Answers to iOS Interview Questions

CTA

iOS and other Apple devices have a great customer base that has helped in building innovative devices viz. iWatch and Apple TV. If you wish to get into a career as an iOS App Developer, then this is the perfect platform. In this iOS Interview Questions blog, we have cumulated a list of mostly asked iOS interview questions. Read through the list of these iOS interview questions and answers and get a head-start in your career in iOS development:
Q1. What are the characteristics of iOS?
Q2. Which JSON framework is supported by iOS (iPhone OS)?
Q3. What is an unnamed category?
Q4. Name the framework that is used to construct the application’s user interface for iOS.
Q5. Which is the application thread from where UIKit classes should be used?
Q6. What is the difference between Synchronous & Asynchronous tasks?
Q7. How can you respond to state transitions on your app?
Q8. What is Operator Overloading?
Q9. What is TVMLKit?
Q10. What are UI Elements in iOS?

Below are the three categories into which this iOS Interview Questions and Answers blog is divided:
1. Basic

2. Intermediate

3. Advanced

Check out this video on iOS Development Tutorial:

Top iOS Interview Questions and Answers

Youtube subscribe

Basic Interview Questions

1. What are the characteristics of iOS?

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. Which JSON framework is supported by iOS (iPhone OS)?

  • SBJson framework is supported by iOS. It is a JSON parser and generator for Objective-C (Objective-C is the primary programming language we use when writing software for OS X and iOS. It is 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.

3. What is an unnamed category?

An unnamed category has fallen out of favor now that @protocol has been extended to support the @optional methods. Class Extensions @interface Foo() is designed to allow us to declare additional private API— system programming interface (SPI)—that is used to implement the class innards. This typically appears at the top of the .m file. Any methods/properties declared in the class extension must be implemented in the @implementation, just like the methods/properties found in the public @interface. Class extensions can also be used to re-declare a publicly read-only @property as read-write prior to doing @synthesize on the accessors. Example:

Foo.h
@interface Foo:NSObject
@property(readonly, copy) NSString *bar;
-(void) publicSaucing;
@end
Foo.m
@interface Foo()
@property(readwrite, copy) NSString *bar;
- (void) superSecretInternalSaucing;
@end
@implementation Foo
@synthesize bar;
.... must implement the two methods or compiler will warn ....
@end

Get 50% Hike!

Master Most in Demand Skills Now !

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

  • 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

CTA

5. Which is the application thread from where UIKit classes should be used?

Unless it’s stated, use UIKit classes only from your application’s main thread or main dispatch queue. This restriction applies in particular to classes derived from UIResponder or that require modifying the user interface of your app in some way.

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

Synchronous can also be defined as In order. When you perform the synchronous operation, all that follows must wait for the operation to complete before proceeding.
In contrast, “asynchronous” can also be defined as “out of order.” When you do something asynchronously, you can run the following code right away, and the asynchronous process will happen someday. It could be run on a separate thread from the rest of the code. It could easily be rescheduled on the same thread at a later date and you can notify you when it is done.

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

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: To prepare to run as the foreground app
  • applicationDidEnterBackground( ) method: To execute some code when the app is running in the background that may be suspended at any time
  • applicationWillEnterForeground( ) method: To execute some code when the app is moving out of the background
  • applicationWillTerminate( ) method: Called when the app is being terminated

8. What is Operator Overloading?

The process of adding new operators and changing existing ones to do various things is known as operator overloading.

+, *, and / symbols are known as operators.

9. What is TVMLKit?

TVMLKit serves as a bridge between TVML, JavaScript, and your native tvOS software. You can test TVMLKit JS and TVML files from inside your tvOS app using the TVMLKit framework. The JavaScript environment can be used to build TVML objects, styles, views, and view controllers.

10. What are UI Elements in iOS?

The visual elements that we can see in our applications are known as UI elements. Some of these components, such as buttons and text fields, respond to user interactions, while others, such as images and labels, provide information.

Career Transition

Intermediate Interview Questions

11. What is Swift and what is Objective-C?

Swift is a modern programming language created by Apple for iOS, OS X, watchOS, and tvOS apps that combines the best of C and Objective-C, but without the C compatibility issues. Swift follows secure programming patterns while also incorporating modern features to make programming simpler, more versatile, and enjoyable. Swift is welcoming to novice programmers and feels familiar with Objective-C developers.

The primary programming language for writing applications for OS X and iOS is Objective-C. It’s an object-oriented programming language with a dynamic runtime that’s a superset of the C programming language. Objective-C takes C’s syntax, primitive types, and flow control statements and adds class and process definition syntax.

12. What is an NSError in Swift?

The NSError class is a Cocoa class. The knowledge about an error condition is encapsulated in an extendable, object-oriented manner by an NSError object. It includes a predefined error domain, a domain-specific error code, and a user details dictionary with application-specific data.

13. What are the features added in iOS 9?

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.

14. What is the difference between KVC and KVO?

KVC (Key-Value Coding) is a method for accessing an object’s properties using strings at runtime rather than needing to know the property names statically at development time.
KVO (Key-Value Observing) allows a controller or class to monitor changes in a property value. In KVO, an object may request to be informed of any adjustments to a particular property, and the observer is automatically notified if that property’s value changes.

15. Explain the different types of iOS Application States.

You will experience a few app states while using the application. There are five states in the ios application as follows.

  • Not Running

The application is in the Not running state, if the app is not launched yet or if the application is not visible on the screen or also there is the possibility that the application is terminated by the user or by OS.

  • Inactive

An inactive state occurs when the application is not receiving events but the app is running in the background. An app transitions to a different state. when the user locks the screen or the system prompts the user to respond to some event such as a phone call or SMS message is the only time it stays inactive.

  • Active

In an ios application, Active State is the main executive state. In this state, the app is running in the foreground and the UI is accessible.

  • Background

Before being suspended most of all apps enter this state.  If an app requests extra execution time then that will remain in this state for some more time. Also, an application will be launched directly into the background enters this background state instead of the inactive state

  • Suspended

In a suspended state the application does not execute any code. The system purges suspended apps without any notice to make more space for the foreground app when a low-memory condition occurs.

16. What is the difference between retain and assign?

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];  
}

17. What is Dynamic Dispatch?

At runtime, Dynamic Dispatch determines which implementation of a polymorphic procedure, such as a method or a function, to call. This means that when we want to call our methods, such as object methods, we must use this syntax. Swift, on the other hand, does not use dynamic dispatch by default.

18. What is GCD?

The GCD stands for Grand Central Dispatch. It is a low-level API that allows you to manage multiple concurrent operations. It will assist you in increasing the responsiveness of your app by deferring computationally intensive tasks to the context. It’s a simpler concurrency model than locks and threads to deal with.

19. What are the advantages of the Realm framework?

  • To handle all of the work, only a small amount of code is needed.
  • Available in both Object C and Swift.
  • SQLite and Core Data have slower performance.
  • Database files can be shared easily between iOS and Android devices.
  • There is no fee, no charge.
  • There is no limit to the data amount that can be stored.
  • Regardless of huge data sets or massive storage, consistent speed and consistency

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

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

  • Using InterfaceBuilder, we can add a 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!

21. What is SpriteKit and what is SceneKit?

SpriteKit is a platform for creating animated 2D objects quickly and easily.

SceneKit is a platform for 3D graphics rendering that was inherited from OS X.

SpriteKit, SceneKit, and Metal are expected to boost a new generation of mobile games that push the boundaries of what the powerful GPUs in iOS devices can do.

22. Explain a singleton class.

When only one instance of a class is created in the application, that class is called a singleton class. See below:

@interface SomeManager : NSObject
+ (id)singleton;
@end
@implementation SomeManager
+ (id)singleton {
static id sharedMyManager = nil;
@synchronized([MyObject class]){
if (sharedMyManager == nil) {
sharedMyManager = [[self alloc] init];
}
}
return sharedMyManager;
}
@end
//using block
+ (id) singleton {
static SomeManager *sharedMyManager = nil;
static dispatch_once_t  onceToken;
dispatch_once(&onceToken, ^{
sharedMyManager = [[self alloc] init];
});
return sharedMyManager;
}

Certification in Full Stack Web Development

23. Differentiate between a frame and a bound?

A UIView’s bounds are a rectangle with a size (width, height) and position (x,y) relative to its own coordinate system (0,0).

A UIView’s frame is a rectangle with a scale (width, height) and position (x,y) relative to the superview it is located within.

24. How to Prioritize Usability in Design?

To prioritize usability, the design process has broken down into 4 steps:

  • Consider the user’s perspective when designing the user experience.
  • Users, not demographics, are what you should focus on.
  • Consider all of the scenarios in which an app might be useful when promoting it.
  • Even after the app has been released, continue to improve its functionality.

25. Explain iBeacons?

Apple’s introduction of Bluetooth low-energy (BLE) wireless technology, iBeacon, is a new way for iPhones and other iOS users to receive location-based information and services.

26. Describe managed object context and its function.

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 the managed object context include the following:

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

27. Why is the design pattern very important?

Design patterns are important in software design because design patterns are reusable solutions to many common problems. They’re models for writing code that’s simple to comprehend and reuse. The most popular design trends in Cocoa are as follows:

  • Creational: Singleton.
  • Structural: Decorator, Adapter, Facade.
  • Behavioral: Observer, and, Memento

28. What is Concurrency?

Concurrency is a fancy term for “running several tasks at the same time.” On iOS devices, concurrency is commonly used to allow you to run tasks such as downloading or processing data in the background while keeping your user interface sensitive.

29. Mention various ways to achieve concurrency in iOS?

Mainly, there are 3 ways to achieve concurrency in iOS. There are:

  • Grand Central Dispatch
  • OperationQueue
  • Threads

30. What is meant by deadlock?

A deadlock is a situation that occurs when at least two threads are locked on a different resource, and both are waiting for the other resource to finish its job. And no one is able to unlock the resource it is guarding.

31. Explain the lazy property in Swift?

A lazy stored property is one that does not determine its initial value until it is used for the first time. The lazy modifier is written before the declaration of a lazy stored property.

CTA

Learn new Technologies

32. What is the abbreviation of ARC?

ARC stands for Automatic Reference Counting.

Advanced Interview Questions

33. What is the difference between strong, weak, read-only, and copy?

  • Strong: Through the life of the object, the reference count will be increased and the reference will be maintained
  • Weak: It can be said as a non-strong reference that means it refers to the fact that we are referring to an object but not adding to its reference count. It’s often used to establish a parent-child relationship. The parent has a strong connection with the infant, but the child has only a small connection with the parent.
  • Read-only: Initially, The property will be set and it can’t be changed.
  • Copy: It means that when an object is created, we’re copying its value. Also prevents its value from changing.

34. Explain QOS?

QoS stands for the quality of service. It is a class that organizes the work that NSOperation, NSOperationQueue, NSThread artifacts, dispatch queues, and threads do (POSIX threads). By assigning a QoS, you’re telling the system how important it is, and the system prioritizes and schedules it accordingly.

35. What is the use of deinit in swift?

Deinitialization in Swift is the method of deallocating or cleaning up unused class instance objects in order to free up memory space used by machine resources for better memory management. Until a class instance is deallocated, the deinitialization process is usually named.

36. 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?

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 set it to non-atomic can boost the performance.

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

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.

38. Does Objective-C contain private methods?

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 it is defined in .h, it is public.

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

39. What is a plist?

Property list or plist refers to a list that organizes data into named values and lists of values using several object types. These types provide us 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 us to convert hierarchically structured combinations of these basic types of objects to and from standard XML. We can save the XML data to the disk and later use it to reconstruct the original objects.

The user defaults system, which we 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, such as NSColor and NSFont objects, from the user defaults system. However, if objects conform to the NSCoding protocol, they can be archived to NSData objects, which are property-list-compatible objects.

Click here to learn more about iOS in the iOS Development Training!

40. Explain MVC?

MVC is the acronym for “Model-View-Controller.” MVC is a design pattern for web applications that consists of three interconnected components.

Model – A model is where the data is stored.

View – The classes in view are reusable as they don’t have any domain-specific logic.  Controller –  with delegation patterns, the controller act as a communication between the model and view.

The MVC model, also known as the “pattern,” is widely used in the development of modern user interfaces.

41. What is the purpose of reuseIdentifier? What is the benefit of setting it into a non-nil value?

The reuseIdentifier is used to group together the similar rows in a UITableView, i.e., the rows that differ only in their content, otherwise having similar layouts. A UITableView will normally allocate just enough UITableViewCell objects to display the content visible in the table.

If reuseIdentifier is set to a non-nil value, then the UITableView will first attempt to reuse an already allocated UITableViewCell with the same reuseIdentifier when the table view is scrolled. If reuseIdentifier has not been set, then the UITableView will be forced to allocate new UITableViewCell objects for each new item that scrolls into view, potentially leading to laggy animations.

42. What are Swift’s advantages?

The main advantages of Swift are mentioned below:

  • Easy to read
  • Easy to maintain
  • Extremely fast
  • Dynamic libraries
  • Safe programming language
  • Efficient memory management
  • Concise code

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

  • 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.

44. What is an abstract class in Cocoa?

Cocoa doesn’t provide anything called abstract. It can create a class abstract that gets checked only at the runtime while it is not checked at the compile time.

@interface AbstractClass : NSObject
@end
@implementation AbstractClass
+ (id)alloc{
if (self == [AbstractClass class]) {
NSLog(@"Abstract Class can’t be used");
}
return [super alloc];
@end

45. What is the difference between Cocoa and Cocoa Touch?

Cocoa Touch is the result of combining the Foundation and AppKit frameworks, while Cocoa is the result of combining the Foundation and UIKit frameworks. To build API stacks, Cocoa and Cocoa Touch sit on top of other application sets. Media, Core Services, and CoreOS are the other layers.

46. What is NSURLConnection class? Define its types and use cases.

There are two ways of using the NSURLConnection class. One is asynchronous and the other is synchronous.

An asynchronous connection will create a new thread and perform its download process on the new thread. A synchronous connection will block the calling thread while downloading the content and doing its communication.

Many developers think that a synchronous connection blocks only the main thread, which is not true. A synchronous connection will always block the thread from which it is fired. If we fire a synchronous connection from the main thread, the main thread will be blocked. However, if we fire a synchronous connection from a thread other than the main thread, it will be like an asynchronous connection and won’t block our main thread.

In fact, the only difference between synchronous and asynchronous connections is that at runtime a thread will be created for the asynchronous connection while it won’t do the same for a synchronous connection.

In order to create an asynchronous connection, we need to:

  1. Have our URL in an instance of NSString
  2. Convert our string to an instance of NSURL
  3. Place our URL in a URL Request of type NSURLRequest or, in the case of mutable URLs, in an instance of NSMutableURLRequest
  4. Create an instance of NSURLConnection and pass the URL request to it

If you have any doubts or queries related to iOS, get them clarified from iOS experts on our iOS Community

47. Explain Swift’s pattern matching techniques

  • Tuple patterns: Values of corresponding tuple forms are matched using tuple patterns.
  • Type-casting patterns: You can cast or mix styles using type-casting patterns.
  • Wildcard patterns: Every kind and kind of value is matched by wildcard patterns, which disregard them.
  • Optional patterns: To align optional values, optional patterns are used.
  • Enumeration case patterns: The cases of existing enumeration forms are matched by enumeration case patterns.
  • Expression patterns: You may use expression patterns to compare a given value to a given expression.

48. What is the relation between iVar and @property?

iVar is an instance variable. It cannot be accessed unless we create accessors, which are generated by @property. iVar and its counterpart @property can be of different names.

@interface Box : NSObject{
NSString *boxName;
}
@property (strong) NSString *boxDescription;//this will become another ivar
-(void)aMethod;
@end
@implementation Box
@synthesize boxDescription=boxName;//now boxDescription is accessor for name
-(void)aMethod {
NSLog(@"name=%@", boxName);
NSLog(@"boxDescription=%@",self.boxDescription);
NSLog(@"boxDescription=%@",boxDescription); //throw an error
}
@end

49. What is a Guard statement?

If one or more requirements aren’t met, a guard statement is used to pass program control out of a domain. The advantages of guard statement are as follows:

  • It is another way to safely unwrap optionals
  • It provides an early exit
  • It avoids pyramids of doom

The guard statement is written as:

guard condition else {
	
   statements
	
	}

50. How is memory management handled on iOS?

Memory management is crucial in any application, especially important in iOS applications due to memory and other limitations. ARC, MRC, reference forms, and value types are all included. Every iOS developer should be aware of this! Memory leaks and system crashes are all too common in iOS apps due to poor memory management.

Course Schedule

Name Date
Android Training 2021-12-04 2021-12-05
(Sat-Sun) Weekend batch
View Details
Android Training 2021-12-11 2021-12-12
(Sat-Sun) Weekend batch
View Details
Android Training 2021-12-18 2021-12-19
(Sat-Sun) Weekend batch
View Details

14 thoughts on “Top iOS Interview Questions and Answers”

  1. Nice job. Thank You. These questions are very useful for those who wants their career in application development..I love apps

  2. Thanks for sharing the descriptive technical information with this stuff. It’s really helpful to me.

Leave a Reply

Your email address will not be published. Required fields are marked *