iPhone Application Development Interview Questions and Answers

1. What is iPhone OS?

          Ans. iPhone OS runs on iPhone and iPod touch devices. Hardware devices are managed by iPhone OS and provides the technologies needed for implementing native applications on the phone. The OS ships with several system applications such as Mail, Safari, Phone, which provide standard services to the user.

2.What is iPhone sdk?

          Ans. iPhone SDK is available with tools and interfaces needed for developing, installing and running custom native applications. Native applications are built using the iPhone OS’s system frameworks and Objective-C language and run directly on iPhone OS. Native applications are installed physically on a device and can run in presence or absence of network connection.

3.What is iPhone Architecture?

          Ans. It is similar to MacOS X architecture. It acts as an intermediary between the iPhone and iPod hardware an the appearing applications on the screen. The user created applications never interact directly with the appropriate drivers, which protects the user applications from changes to the hardware.

4. What is MVC ? MVC Architecture of iPhone App.?

          Ans. Here are the reasons why we should use the MVC (Model View Controller)design pattern.

          1.  They are resuable : When the problems occurs, there is no need to invent a new solution, we just have to follow the pattern and adopt it as necessary.

          2.  They are expressive: By using the MVC design pattern our application becomes more expressive.

1).  Model: The model object knows about all the data that need to be displayed. It is model who is aware about all the operations that can be applied to transform that object. It only represents the data of an application. The model represents enterprise data and the business rules that govern access to and updates of this data. Model is not aware about the presentation data and how that data will be displayed to the browser.

2). View: The view represents the presentation of the application. The view object refers to the model. It uses the query methods of the model to obtain the contents and renders it. The view is not dependent on the application logic. It remains same if there is any modification in the business logic. In other words, we can say that it is the responsibility of the of the view’s to maintain the consistency in its presentation when the model changes.

3). Controller:  Whenever the user sends a request for something then it always go through the controller. The controller is responsible for intercepting the requests from view and passes it to the model for the appropriate action. After the action has been taken on the data, the controller is responsible for directing the appropriate view to the user. In  GUIs, the views and the controllers often work very closely together.

5.What are the ways to store data localy on device ?

          Ans. We store data localy in device through:

          1.  Plist.

          2.  NSUserDefaults.

          3.  SQLite.

          4.  CoreData.

6.Difference between COCOA,COCOA touch and objective C ?

          Ans. Objective C is a dynamic programming language – a bit like C++ and a bit like Java.

Cocoa is the application framework for Mac OS X. Cocoa Touch is the application framework for iPhone and iPod Touch – very similar to Cocoa. Cocoa is commonly referred to as the combination of the Foundation and AppKit frameworks, while Cocoa Touch is the combination of the Foundation and UIKit frameworks. Cocoa and Cocoa Touch sit on top of other collections of frameworks to create the API stacks. The other layers are Media, Core Services and Core OS. The main difference between Cocoa and Cocoa touch is that the UI classes and APIs aren’t the same as Mac OS X, so instead of NSTextField, you have UITextField. Many of the classes share the same functionality and can be ported quite easily by simply changing the class name, though most will require some more changes, but usually nothing too heavy. There are also some differences between the Foundation frameworks in Cocoa and Cocoa Touch, most commonly missing classes, eg, Cocoa has NSHost and Cocoa Touch doesn’t.

7.Difference between shallow copy and deep copy?

          Ans. Shallow copy is also known as address copy. In this process you only copy address not actual data while in deep copy you copy data. Suppose there are two objects A and B. A is pointing to a different array while B is pointing to different array. Now what I will do is following to do shallow copy.
Char *A = {‘a’,’b’,’c’};
Char *B = {‘x’,’y’,’z’};
B = A;
Now B is pointing is at same location where A pointer is pointing.Both A and B in this case sharing same data. if change is made both will get altered value of data.Advantage is that coping process is very fast and is independent of size of array.while in deep copy data is also copied. This process is slow but Both A and B have their own copies and changes made to any copy, other will copy will not be affected.

8. What is advantage of categories? What is difference between implementing a category and inheritance?

          Ans. You can add method to existing class even to that class whose source is not available to you. You can extend functionality of a class without subclassing. You can split implementation in multiple classes. While in Inheritance you subclass from parent class and extend its functionality.

9.Flow of push notification?

          Ans. Your web server sends message (device token + payload) to Apple push notification service (APNS) , then APNS routes this message to device whose device token specified in notification.

10.What is polymorphism?

          Ans. This is very famous question and every interviewer asks this. Few people say polymorphism means multiple forms and they start giving example of draw function which is right to some extent but interviewer is looking for more detailed answer. Ability of base class pointer to call function from derived class at runtime is called polymorphism. For example, there is super class human and there are two subclasses software engineer and hardware engineer. Now super class human can hold reference to any of subclass because software engineer is kind of human. Suppose there is speak function in super class and every subclass has also speak function. So at runtime, super class reference is pointing to whatever subclass, speak function will be called of that class. I hope I am able to make you understand.

11.When to use NSMutableArray and when to use NSArray?

          Ans. Normally we use mutable version of array where data in the array will change. For example, you are passing a array to function and that function will add some elements to that array or will remove some elements from array, then you will select NSMutableArray. When you don’t want to change you data, then you store it into NSArray. For example, the country names you will put into NSArray so that no one can accidentally modify it.

12. How is the app delegate is declared by Xcode project templates?

          Ans. App delegate is declared as a subclass of UIResponder by Xcode project templates.

13. What is the purpose of UIWindow object?

Ans. The presentation of one or more views on a screen is coordinated by UIWindow object.

14. Whats the difference between frame and bounds?

          Ans. 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).

15. What is @interface?

          Ans. It’s a keyword used to declare the Class.

16.What is @implementation?

          Ans. It’s a keyword used to define the Class.

17. Garbage collector in iPhone?

          Ans. iOS 5.0 has got the ARC ( Automated reference counting ). Objective C does not have a garbage collector rather it uses the reference counting algorithm to manage the memory. This was the developers task until Apple launched iOS 5.0. Again if you are targeting iOS 4.0 or earlier , ARC is no more a choice for you.

18.What is delegate?

          Ans.  Delegate is an object that handles the events happening on an object. To do that delegate has to follow a protocol specifying the task it is going to handle .

19. What is @synthesize?

          Ans. We use @synthesize to generate getters and setters automatically from compiler. We declare properties and then generate getter and setter method by using @synthesize.

20.What is nonatomic ?

          Ans.  nonatomic and atomic are related to multithreading environment . If a property has an attribute as “nonatomic” that means multiple threads can modify that property concurrently. If the attribute is “atomic”, the threads would be given access atomically. So “Atomic” is thread safe while “nonatomic” is thread unsafe. Atomic drastically hampers the performance so until and unless not needed you should never go for atomic attribute. ‘nonatomic ’ will do in most of the cases.

21.What is @dynamic and any place where it is used ?

          Ans. It tells compiler that getter and setter are not implemented by the class but by some other class.

May be super class or child class.

Example – Core Data.

– The Managed object classes have properties defined by using @dynamic.

22.What are the delegate methods of MKMapView ?

          Ans. Firstly you have added the storeKit.framework in your xcode project then define the protocol as <MKMapviewDelegate> in .h file.

- (void)mapView:(MKMapView *)mapView regionWillChangeAnimated:(BOOL)animated;
- (void)mapView:(MKMapView *)mapView regionDidChangeAnimated:(BOOL)animated;
- (void)mapViewWillStartLoadingMap:(MKMapView *)mapView;
- (void)mapViewDidFinishLoadingMap:(MKMapView *)mapView;
- (void)mapViewDidFailLoadingMap:(MKMapView *)mapView withError:(NSError *)error;
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id)annotation;
- (void)mapView:(MKMapView *)mapView didAddAnnotationViews:(NSArray *)views;

23.What are the important delegate methods of NSXML parser?






23. How many bytes we can send to apple push notification server.?


24.Does iOS support multitasking?

Ans: 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.

25.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. Form iOS 5 Onwards we are using NSJSONSerialization inherited from NSObject Base class.

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

          Ans: On 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.

27.Who calls the main function of you app during the app launch cycle?

          Ans: During app launching, the system creates a main thread for the app and calls the app’s main function on that main thread. The Xcode project’s default main function hands over control to the UIKit framework, which takes care of initializing the app before it is run.

28.Difference between categories and extensions?

          Ans: Class extensions are similar to categories. The main difference is that with an extension, the compiler will expect you to implement the methods within your main @implementation, whereas with a category you have a separate @implementation block. So you should pretty much only use an extension at the top of your main .m file (the only place you should care about ivars, incidentally) — it’s meant to be just that, an extension.

29.What are KVO and KVC?

          Ans: KVC(Key Value Coding)  Normally instance variables are accessed through properties or accessors but KVC gives another way to access variables in form of strings. In this way your class acts like a dictionary and your property name for example “age” becomes key and value that property holds becomes value for that key. For example, you have employee class with name property. You access property like NSString age = emp.age; setting property value. emp.age = @”20″; Now how KVC works is like this [emp valueForKey:@”age”]; [emp setValue:@”25″ forKey:@”age”];

KVO (Key Value Observation): The mechanism through which objects are notified when there is change in any of property is called KVO. For example, person object is interested in getting notification when accountBalance property is changed in BankAccount object.To achieve this, Person Object must register as an observer of the BankAccount’s accountBalance property by sending an addObserver:forKeyPath:options:context: message.:

30.What is difference between NSNotification and delegate?

          Ans : Delegate is passing message from one object to other object. It is like one to one communication while nsnotification is like passing message to multiple objects at the same time. All other objects that have subscribed to that notification or acting observers to that notification can or can’t respond to that event. Notifications are easier but you can get into trouble by using those like bad architecture. Delegates are more frequently used and are used with help of protocols.

31. Difference  between protocol and delegates?

Ans: A protocol, declared with the (@protocol syntax in Objective-C) is used the declare a set of methods that a class that “adopts” (declares that it will use this protocol) will implement. This means that you can specify in your code that, “you don’t care which class is used so long as it implements a particular protocol”. This can be done in Objective-C as follows:

id<MyProtocol> instanceOfClassThatImplementsMyProtocol;

If you state this in your code, then any class that “conforms” to the protocol MyProtocol can be used in the variable instanceOfClassThatImplementsMyProtocol. This means that the code that uses this variable knows that it can use whichever methods are defined in MyProtocol with this particular variable, regardless of what class it is. This is a great way of avoiding the inheritance design pattern, and avoids tight coupling.

Delegates are a use of the language feature of protocols. The delegation design pattern is a way of designing your code to use protocols where necessary. In the Cocoa frameworks, the delegate design pattern is used to specify an instance of a class which conforms to a particular protocol. This particular protocol specifies methods that the delegate class should implement to perform specific actions at given events. The class that uses the delegate knows that its delegate coforms to the protocol, so it knows that it can call the implemented methods at given times. This design pattern is a great way of decoupling the classes, because it makes it really easy to exchange one delegate instance for another – all the programmer has to do is ensure that the replacement instance or class conforms to the necessary protocol (i.e. it implements the methods specified in the protocol)!

Protocols and delegates are not restricted only to Objective-C and Mac/iOS development, but the Objective-C language and the Apple frameworks make heavy use of this awesome language feature and design pattern.


Here’s an example. In the UIKit framework of Cocoa Touch, there is a UITextFieldDelegate protocol. This protocol defines a series of methods that classes which are delegates of a UITextField instance should implement. In other words, if you want to assign a delegate to a UITextField (using thedelegate property), you’d better make sure that this class conforms to UITextFieldDelegate. In fact, because the delegate property of UITextField is defined as:

@property(nonatomic, assign) id<UITextFieldDelegate> delegate

Then the compiler will give warnings if you assign a class to it that doesn’t implement the protocol. This is really useful. You have to state that a class implements a protocol, and in saying that it does, you’re letting other classes know that they can interact in a particular way with your class. So, if you assign an instance of MyTextFieldDelegateClass to the delegate property of UITextField, the UITextFieldknows that it can call some particular methods (related to text entry, selection etc.) of yourMyTextFieldDelegateClass. It knows this because MyTextFieldDelegateClass has said that it will implement the UITextFieldDelegate protocol.

Ultimately, this all leads to much greater flexibility and adaptability in your project’s code, which I’m sure you’ll soon realise after using this technology! 🙂

protocol Directives :- @optional, @required.

32.What is Automatic Reference Counting (ARC) ?

Ans: 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.

33. Whats 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.)

for(id item in myObjects)


NSLog(@”Found an Item: %@”,item);


34. . Whats 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.



 uint8_t header[16];  // This would be MD5 of String “SymbolTalk”

uint8_t type;  // Type of structure -> FILE_TRANSFER_RESPONSE


35. How can we achieve singleton pattern in iOS?

          Ans: The Singleton design pattern ensures a class only has one instance, and provides a global point of access to it. The class keeps track of its sole instance and ensures that no other instance can be created. Singleton classes are appropriate for situations where it makes sense for a single object to provide access to a global resource.

36.What is run loop in iOS ?

          Ans: Run loops are part of the fundamental infrastructure associated with threads. A run loop is an event processing loop that you use to schedule work and coordinate the receipt of incoming events. The purpose of a run loop is to keep your thread busy when there is work to do and put your thread to sleep when there is none. Run loop management is not entirely automatic. You must still design your thread’s code to start the run loop at appropriate times and respond to incoming events. Both Cocoa and Core Foundation provide run loop objects to help you configure and manage your thread’s run loop. Your application does not need to create these objects explicitly; each thread, including the application’s main thread, has an associated run loop object. Only secondary threads need to run their run loop explicitly, however. In both Carbon and Cocoa applications, the main thread automatically sets up and runs its run loop as part of the general application startup process.

37.When will be the autorelease object released?

          Ans: Once the pool receives drain message.

38.What is the difference between copy & retain?

Ans : In a general setting, retaining an object will increase its retain count by one. This will help keep the object in memory and prevent it from being blown away. What this means is that if you only hold a retained version of it, you share that copy with whomever passed it to you. Copying an object, however you do it, should create another object with duplicate values. Think of this as a clone. You do NOT share the clone with whomever passed it to you. When dealing with NSStrings in particular, you may not be able to assume that whoever is giving you an NSString is truly giving you an NSString. Someone could be handing you a subclass (NSMutableString, in this case) which means that they could potentially modify the values under the covers. If your application depends on the value passed in, and someone changes it on you, you can run into trouble.

39. What you mean by blocks ?

          Ans: 1. An extension to the C language and its derivatives Objective c and c++ , introduced by apple.

               2. Available iOS 4.0 onwards

               3. Functional style of coding, less boilerplate code, more readable, simple even driven scenarios, powerful mutli-threading.

               4. Pointer to a function, a copy of some of the local variables of its higher order function .

               5.a bunch of code can be passed as an argument of a function.

               6. High power of execution and callback.

40. What you mean by GCD(Grand central Dispatch) ?

          Ans : more powerful than the threads, it’s will utilize the all core’s of the iphone. GCD is based on the thread pool pattern. Implementation (Dispatch queue , Dispatch Source , Dispatch Groups . dispatch semaphores)

          Eg : dispatch_async(queue,block),  dispatch_sync(queue,block), dispatch_after(when,queue,block), dispatch_apply(iterations,queue,block),dispatch_once(queue,block)

41.What you mean by auto layout in Objective C?

          Ans : Auto Layout is a new way to define dynamic GUIs. Before we had autoresizing masks, that described how a subview will resize or move when it’s superview is resized. With Auto Layout you can do the same and also a lot more complicated GUIs quite easily.

42. When is the autorelease pool triggered ?

     Ans: 1.Beginning and very end of your application life-cycle, written in main.m

int main(int argc, char *argv[]) {

    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];

    int retVal = UIApplicationMain(argc, argv, nil, nil);

    [pool release];

    return retVal;


2.Beginning and very end of each event (Done in the AppKit)

NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];  – (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath  – (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil  – (void)loadView  /* etc etc initialization stuff… */ [pool release];

3.Whenever you want (you can create your own pool and release it. [from apples memory management document])

– (id)findMatchingObject:anObject {   id match = nil;   while (match == nil) {       NSAutoreleasePool *subPool = [[NSAutoreleasePool alloc] init];       /* Do a search that creates a lot of temporary objects. */       match = [self expensiveSearchForObject:anObject];       if (match != nil) {           [match retain]; /* Keep match around. */       }       [subPool release];   }   return [match autorelease];   /* Let match go and return it. */ }

43. What’s the difference between a method and a selector?

 Ans:  Selector – a Selector is the name of a method. You’re very familiar with these selectors: alloc,init, release, dictionaryWithObjectsAndKeys:, setObject:forKey:, etc. Note that the colon is part of the selector; it’s how we identify that this method requires parameters. Also (though it’s extremely rare), you can have selectors like this: doFoo:::. This is a method that takes three parameters, and you’d invoke it like [someObject doFoo:arg1 :arg2 :arg3]. There’s no requirement that there be letters before each part of the selector components. As I said, this is extremely rare, and you will not find it used in the Cocoa frameworks. You can work with selectors directly in Cocoa. They have the type SEL: SEL aSelector = @selector(doSomething:) or SEL aSelector = NSSelectorFromString(@”doSomething:”);

·    Message – a message is a selector and the arguments you are sending with it. If I say[dictionary setObject:obj forKey:key], then the “message” is the selectorsetObject:forKey: plus the arguments obj and key. Messages can be encapsulated in anNSInvocation object for later invocation. Messages are sent to a receiver. (ie, the object that “receives” the message).

·    Method – a method is a combination of a selector and an implementation (and accompanying metadata). The “implementation” is the actual block of code; it’s a function pointer (an IMP). An actual method can be retrieved internally using a Method struct (retrievable from the runtime).


Some other related things that you didn’t ask for:

·    Method Signature – a method signature represents the data types returned by and accepted by a method. They can be represented at runtime via an NSMethodSignature and (in some cases) a raw char*.

·    Implementation – the actual executable code of a method. Its type at runtime is an IMP, and it’s really just a function pointer. iOS 4.3 includes a new ability to turn a block into an IMP. This isreally cool.

44. performSelectorInBackground vs  dispatch_async


    [self performSelectorInBackground:@selector(callXml:)                     withObject:@”test”];

ie: what you pass in as withObject: becomes the parameter to your method.

Just as a point of interest here’s how you could do it using GCD:

dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ [self callXml:@”test”];      // If you then need to execute something making sure it’s on the main thread (updating the UI for example)     dispatch_async(dispatch_get_main_queue(), ^{      [self updateGUI]; }); });

45. What you mean by Open url ?

[[UIApplication sharedApplication] openURL:[NSURL URLWithString: @”http://www.forasinvest.com/v2/index.php”]];

This will help you to open the external apps and link’s

46. Which framework used for passbook in objective c ?

          Ans: Passkit framework , passkit file come up with an extension of .pkpass

Leave a Reply

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