iOS Interview Questions

Top IOS Interview Questions And Answers

IOS Interview Questions

Top IOS Interview Questions And Answers

Here are top 18 objective type sample IOS Interview questions and their answers are given just below to them. These sample questions are framed by experts fr…   read more 

Top Answers to IOS Interview Questions

1.IOS Characteristics
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 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 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.

3.How can we prevent 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 black out out in the recording.
• HTTP Live Streaming: – Send 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 you deploy 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.Name the framework that is used to construct application’s user interface for iOS

• The UIKit framework is used to develop application’s user interface. 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 user input, and
-> 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 your 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

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

6.What are the features added in iOS 9?

Intelligent Search and Siri- Intelligent Search 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 is a personal assistant to the users, able to create contextual reminders and search through photos and videos in new ways. Swiping right from the home screen also brings up a new screen that houses “Siri Suggestions,” putting favorite contacts and apps right on your fingertips, along with nearby restaurant and location information and important news.
• Deeper search capabilities can show results like sports scores, videos, and content from third-party apps, and you can even do simple conversions and calculations using the search tools on your iPhone or iPad.Performance improvements
• Many of the built-in apps have been improved.
✓ Notes includes new checklists and sketching features
✓ Maps now offers transit directions
✓ Mail allows for file attachments, and
New “News” app that learns your interests and delivers relevant content you might like to read.
✓ Apple Pay is being improved with the addition of store credit cards and loyalty cards
✓ Leading “Passbook” to be renamed to “Wallet” in iOS 9.
San Francisco font, wireless CarPlay support
• An optional iCloud Drive app, built-in two factor authentication and optional longer passwords for better security.

7.What is the difference between retain & 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];  
8.What are the different ways to specify layout of elements in UIView?
Here are a few common ways to specify the layout of elements in UIView:
Using InterfaceBuilder, you can add a 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.
9.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’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 to 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.
10.Describe managed object context and is function.
• A managed object context (represented by an instance of NSManagedObjectContext) is a temporary “scratch pad” 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.
11.Explain Singleton class.

Only one instance of that class is created in the application.

@interface SomeManager : NSObject
             + (id)singleton;
 @implementation SomeManager
            + (id)singleton {    
                                 static id sharedMyManager = nil; 
                                 @synchronized([MyObject class]){ 
                                                     if (sharedMyManager == nil) { 
                                                                         sharedMyManager = [[self alloc] init]; 
                                return sharedMyManager;
//using block
+ (id) singleton {
    static SomeManager *sharedMyManager = nil;
    static dispatch_once_t  onceToken;
    dispatch_once(&onceToken, ^{
        sharedMyManager = [[self alloc] init];
    return sharedMyManager;
12.What is unnamed category
Unnamed Category has fallen out of favor now that @protocol has been extended to support @optional methods.
A class extension –
@interface Foo() — is designed to allow you to declare additional private API — SPI or System Programming Interface — 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 readonly @property as readwrite prior to @synthesize’ing the accessors.

@interface Foo:NSObject
@property(readonly, copy) NSString *bar;
-(void) publicSaucing;
@interface Foo()
@property(readwrite, copy) NSString *bar;
- (void) superSecretInternalSaucing;
@implementation Foo
@synthesize bar;
.... must implement the two methods or compiler will warn ....
13.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 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
14.What is plist?
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 as 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
15.What is the purpose of reuseIdentifier? What is the benefit of setting it to a non-nil value?
• The reuseIdentifier is used to group together similar rows in a UITableView; i.e., rows that differ only in their content, but otherwise have 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 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, the UITableView will be forced to allocate new UITableViewCell objects for each new item that scrolls into view, potentially leading to laggy animations.
16.What is the difference between an “app ID” and a “bundle ID” and what is each used for?
• An App ID is a two-part string to identify one or more apps from a single development team. The string consists of a Team ID and a bundle ID search string, with a period (.) separating the two parts.
• The Team ID is supplied by Apple and is unique to a specific development team while a bundle ID search string is supplied by the developer to match either the bundle ID of a single app or a set of bundle IDs for a group of apps.
Since most users consider the App ID as string, they think it is interchangeable with Bundle ID. Once the App ID is created in the Member Center, you 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, output multiple apps. A common use case for this – An app having both lite/free and pro/full versions or branded multiple ways.
17.What is Abstract class in Cocoa?

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

@interface AbstractClass : NSObject
@implementation AbstractClass
+ (id)alloc{
    if (self == [AbstractClass class]) {
        NSLog(@"Abstract Class can’t be used");
    return [super alloc];
18.What is NSURLConnection class? Define its types and use case.
There are two ways of using NSURLConnection class. One is asynchronous and the other is synchronous.
An asynchronous connection will create a new thread and performs its download process on the new thread. A synchronous connection will block the calling thread while downloading content and doing its communication.
Many developers think that a synchronous connection blocks the main thread, which is not true. A synchronous connection will always block the thread from which it is fired. If you fire a synchronous connection from the main thread, the main thread will be blocked. But, if you fire a synchronous connection from a thread other than the main thread, it will be like an asynchronous connection and won’t block your main thread.
In fact, the only difference between a synchronous and an asynchronous connection 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 do the following:
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.
19.What is the relation between iVar and @property?

iVar is an instance variables. 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
@implementation Box
@synthesize boxDescription=boxName;//now boxDescription is accessor for name
-(void)aMethod {
    NSLog(@"name=%@", boxName);
    NSLog(@"boxDescription=%@",boxDescription); //throw an error