IOS Interview Questions and Answers
ANS: iOS (known as iPhone OS prior to June 2010) is Apple’s mobile operating system. Originally developed for the iPhone, it has since been extended to support other Apple devices such as the iPod touch, iPad and Apple TV. Apple does not license iOS for installation on third-party hardware.
2. Does iOS support multitasking?
A. 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.
3. Which JSON framework is supported by iOS?
ANS: 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.
4. What are the tools required to develop iOS applications?
ANS: iOS development requires Intel-based Macintosh computer and iOS SDK.
5. Name the framework that is used to construct application’s user interface for iOS?
ANS: 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.
6. Why an app on iOS device behaves differently when running in foreground than in background?
ANS: An application behaves differently when running in foreground than in background because of the limitation of resources on iOS devices.
7. How would you create your own custom view?
ANS: Subclass the UIView class.
8. What’s fast enumeration?
ANS: 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.)
9. What’s a struct?
ANS: 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.
10. What’s the difference between a NSArray and a NSMutableArray?
ANS: A 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.
11. Explain retain counts?
ANS: 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 auto release 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.
12. What’s the difference between frame and bounds?
The frame of a view is the rectangle, expressed as a location (x,y) and size (width, height) relative to the super view 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).
13. Is a delegate retained?
ANS: No, the delegate is never retained! Ever!
14. What’s the NSCoder class used for?
ANS: 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 encode Object and decode Object methods in them).
15. 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.
16. Explain the correct way to manage Outlets memory ?
ANS: Create them as properties in the header that are retained. In the view Did Unload set the outlets to nil (i.e. self. outlet = nil). Finally in dealloc make sure to release the outlet.
17. Is the delegate for a CAAnimation retained?
ANS: Yes it is!! This is one of the rare exceptions to memory management rules.
18. What happens when the following code executes?
ANS: Ball *ball = [[[[Ball alloc] init] auto release] auto release];
It will crash because it’s added twice to the auto release pool and when it it dequeued the auto release pool calls release more than once.
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.
19. Explain the difference between NSOperationQueue concurrent and non-concurrent?
ANS: In the context of an NSOperation object, which runs in an NSOperationQueue, the terms concurrent and non-concurrent 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.
20. What happens when you call auto release on an object?
ANS: When you create a object with auto release it is added to the auto release pool of the system and the objects retain count is decremented when the auto release pool is flushed in the next cycle. So basically as the name suggests auto release objects are auto released by the system, no object owns them. If you want to use these objects later your object needs to retain it and then release it when you are done.
For iPhone Online training please log on to http://www.revanthtechnologies.com