• USA : +1 973 910 5725
  • INDIA: +91 905 291 3388
  • info@tekslate.com
  • Login

IOS Development Interview Questions

Where can you test Apple iPhone apps if you don’t have the device?

iOS Simulator can be used to test mobile applications. Xcode tool that comes along with iOS SDK includes Xcode IDE as well as the iOS Simulator. Xcode also includes all required tools and frameworks for building iOS apps.  However, it is strongly recommended to test the app on the real device before publishing it.

Does iOS support multitasking?


 iOS 4 and above supports multi-tasking and allows apps to remain in the background until they are launched again or until they are terminated.

Which JSON framework is supported by iOS?


SBJson framework is supported by iOS.  It is a JSON parser and generator for Objective-C. SBJson provides flexible APIs and additional control that makes JSON handling easier.

What are the tools required to develop iOS applications?


 iOS development requires Intel-based Macintosh computer and iOS SDK.

 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 for iOS. UIKit framework provides event handling, drawing model, windows, views, and controls specifically designed for a touch screen interface.

 Name the application thread from where UIKit classes should be used?


UIKit classes should be used only from an application’s main thread.  Note: The derived classes of UIResponder and the classes which manipulate application’s user interface should be used from application’s main thread.

Which API is used to write test scripts that help in exercising the application’s user interface elements?


UI Automation API is used to automate test procedures. Tests scripts are written in JavaScript to the UI Automation API.  This in turn simulates user interaction with the application and returns log information to the host computer.

What is App Bundle?

When you build your iOS app, Xcode packages it as a bundle. A bundle is a directory in the file system that groups related resources together in one place. An iOS app bundle contains the app executable file and supporting resource files such as app icons, image files, and localized content.

Whats fast enumeration?

Fast enumeration is a language feature that allows you to enumerate over the contents of a collection. (Your code will also run faster because the internal implementation reduces message send overhead and increases pipelining potential.)

Whats a struct?

A struct is a special C data type that encapsulates other pieces of data into a single cohesive unit. Like an object, but built into C.

What’s the difference between  NSArray and  NSMutableArray?

NSArrayʼs contents can not be modified once itʼs been created whereas a NSMutableArray can be modified as needed, i.e items can be added/removed from it.

Explain retain counts.

Retain counts are the way in which memory is managed in Objective-C. When you create an object, it has a retain count of 1. When you send an object a retain message, its retain count is incremented by 1. When you send an object a release message, its retain count is decremented by 1. When you send an object a autorelease message, its retain count is decremented by 1 at some stage in the future. If an objectʼs retain count is reduced to 0, it is deallocated.

Capture.586

Why an app on iOS device behaves differently when running in foreground than in background?


 An application behaves differently when running in foreground than in background because of the limitation of resources on iOS devices.

How can an operating system improve battery life while running an app?


 An app is notified whenever the operating system moves the apps between foreground and background.  The operating system improves battery life while it bounds what your app can do in the background. This also improves the user experience with foreground app.

Which framework delivers event to custom object when app is in foreground?


The UIKit infrastructure takes care of delivering events to custom objects. As an app developer, you have to override methods in the appropriate objects to process those events.

What’s the difference between frame and bounds?

A:The frame of a view is the rectangle, expressed as a location (x,y) and size (width,height) relative to the superview it is contained within. The bounds of a view is the rectangle, expressed as a location (x,y) and size (width,height) relative to its own coordinate system (0,0).

Is a delegate retained?

No, the delegate is never retained! Ever!

Outline the class hierarchy for a UIButton until NSObject.

UIButton inherits from UIControl, UIControl inherits from UIView, UIView inherits from UIResponder, UIResponder inherits from the root class NSObject.

What are the App states. Explain them?

Not running State:  The app has not been launched or was running but was terminated by the system.

Inactive state: The app is running in the foreground but is currently not receiving events. (It may be executing other code though.) An app usually stays in this state only briefly as it transitions to a different state. The only time it stays inactive for any period of time is when the user locks the screen or the system prompts the user to respond to some event, such as an incoming phone call or SMS message.

Active state: The app is running in the foreground and is receiving events. This is the normal mode for foreground apps.

Background state:  The app is in the background and executing code. Most apps enter this state briefly on their way to being suspended. However, an app that requests extra execution time may remain in this state for a period of time. In addition, an app being launched directly into the background enters this state instead of the inactive state. For information about how to execute code while in the background, see “Background Execution and Multitasking.”

Suspended state:The app is in the background but is not executing code. The system moves apps to this state automatically and does not notify them before doing so. While suspended, an app remains in memory but does not execute any code. When a low-memory condition occurs, the system may purge suspended apps without notice to make more space for the foreground app.

Why do we need to use @Synthesize?

We can use generated code like nonatomic, atmoic, retain without writing any lines of code. We also have getter and setter methods. To use this, you have 2 other ways: @synthesize or @dynamic: @synthesize, compiler will generate the getter and setter automatically for you, @dynamic: you have to write them yourself.@property is really good for memory management, for example: retain.How can you do retain without @property? 

if (_variable != object)

{

    [_variable release];

    _variable = nil;

    _variable = [object retain];

    }

How can you use it with @property?self.variable = object; When we are calling the above line, we actually call the setter like [self setVariable:object] and then the generated setter will do its job.

When an app is said to be in not running state?


 An app is said to be in ‘not running’ state when:
– it is not launched.
– it gets terminated by the system during running.

 Assume that your app is running in the foreground but is currently not receiving events. In which state it would be in?


 An app will be in InActive state if it is running in the foreground but is currently not receiving events. An app stays in InActive state only briefly as it transitions to a different state.

Give example scenarios when an application goes into InActive state?


An app can get into InActive state when the user locks the screen or the system prompts the user to respond to some event e.g. SMS message, incoming call etc.

When an app is said to be in active state?


An app is said to be in active state when it is running in foreground and is receiving events.

Name the app sate which it reaches briefly on its way to being suspended.


An app enters background state briefly on its way to being suspended.

 Assume that an app is not in foreground but is still executing code. In which state will it be in?


 Background state.

 An app is loaded into memory but is not executing any code. In which state will it be in?


An app is said to be in suspended state when it is still in memory but is not executing any code.

Explain the options and bars available in xcode 4.x workspace window ?

[block]1[/block]

If I call performSelector:withObject:afterDelay: – is the object retained?

Yes, the object is retained. It creates a timer that calls a selector on the current threads run loop. It may not be 100% precise time-wise as it attempts to dequeue the message from
the run loop and perform the selector.

Can you explain what happens when you call autorelease on an object?

When you send an object a autorelease message, its retain count is decremented by 1 at some stage in the future. The object is added to an autorelease pool on the current thread. The main thread loop creates an autorelease pool at the beginning of the function, and release it at the end. This establishes a pool for the lifetime of the task. However, this also means that any autoreleased objects created during the lifetime of the task are not disposed of until the task completes. This may lead to the taskʼs memory footprint increasing unnecessarily. You can also consider creating pools with a narrower scope or use NSOperationQueue with itʼs own autorelease pool. (Also important – You only release or autorelease objects you own.)

 What’s the NSCoder class used for?

NSCoder is an abstract Class which represents a stream of data. They are used in Archiving and Unarchiving objects. NSCoder objects are usually used in a method that is being implemented so that the class conforms to the protocol. (which has something like encodeObject and decodeObject methods in them).

What’s an NSOperationQueue and how/would you use it?

The NSOperationQueue class regulates the execution of a set of NSOperation objects. An operation queue is generally used to perform some asynchronous operations on a background thread so as not to block the main thread.

Explain the correct way to manage Outlets memory.

Create them as properties in the header that are retained. In the viewDidUnload set the outlets to nil(i.e self.outlet = nil). Finally in dealloc make sure to release the outlet.

What is sandbox?

For security reasons, iOS places each app (including its preferences and data) in a sandbox at install time. A sandbox is a set of fine-grained controls that limit the app’s access to files, preferences, network resources, hardware, and so on. As part of the sandboxing process, the system installs each app in its own sandbox directory, which acts as the home for the app and its data.

To help apps organize their data, each sandbox directory contains several well-known subdirectories for placing files. Above Figure shows the basic layout of a sandbox directory.

Is the delegate for a CAAnimation retained?

Yes it is!! This is one of the rare exceptions to memory management rules.

What is dynamic?

You use the @dynamic keyword to tell the compiler that you will fulfill the API contract implied by a property either by providing method implementations directly or at runtime using other mechanisms such as dynamic loading of code or dynamic method resolution. It suppresses the warnings that the compiler would otherwise generate if it can’t find suitable implementations. You should use it only if you know that the methods will be available at runtime.

 What happens when the following code executes?

Ball *ball = [[[[Ball alloc] init] autorelease] autorelease];

It will crash because itʼs added twice to the autorelease pool and when it it dequeued the autorelease pool calls release more than once.

Explain the difference between NSOperationQueue concurrent and non-concurrent.

In the context of an NSOperation object, which runs in an NSOperationQueue, the terms concurrent and nonconcurrent do not necessarily refer to the side-by-side execution of threads. Instead, a non-concurrent operation is one that executes using the environment that is provided for it while a concurrent operation is responsible for setting up its own execution environment.

 Implement your own synthesized methods for the property NSString *title.

Well you would want to implement the getter and setter for the title object. Something like this: view source print?

– (NSString*) title // Getter method

{

return title;

}

– (void) setTitle: (NSString*) newTitle //Setter method

{

if (newTitle != title)

{

[title release];

title = [newTitle retain]; // Or copy, depending on your needs.

}

}

Implement the following methods: retain, release, autorelease.

-(id)retain

{

NSIncrementExtraRefCount(self);

return self;

}

-(void)release

{

if(NSDecrementExtraRefCountWasZero(self))

{NSDeallocateObject(self);

}

}

-(id)autorelease

{ // Add the object to the autorelease pool

[NSAutoreleasePool addObject:self];

return self;

}

What are all  the newly added frameworks iOS 4.3 to iOS 5.0?

 -Accounts

– CoreBluetooth

– CoreImage

– GLKit

– GSS

– Newsstand Kit

– Twitter

 What is Automatic Reference Counting (ARC) ?

ARC is a compiler-level feature that simplifies the process of managing the lifetimes of Objective-C objects. Instead of you having to remember when to retain or release an object, ARC evaluates the lifetime requirements of your objects and automatically inserts the appropriate method calls at compile time.

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

}

Summary
Review Date
Reviewed Item
IOS Development Interview Questions
Author Rating
5

“At TekSlate, we are trying to create high quality tutorials and articles, if you think any information is incorrect or want to add anything to the article, please feel free to get in touch with us at info@tekslate.com, we will update the article in 24 hours.”

0 Responses on IOS Development Interview Questions"

    Leave a Message

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

    Site Disclaimer, Copyright © 2016 - All Rights Reserved.

    Support


    Please leave a message and we'll get back to you soon.

    I agree to be contacted via e-mail.