Home  >  Blog  >   iPhone

IOS Development Interview Questions - IPhone

Rating: 4.5
  
 
24266
  1. Share:

If you're looking for IOS Development Interview Questions for Experienced or Freshers, you are at the right place. There are a lot of opportunities from many reputed companies in the world. According to research IOS Development has a market share of about 12.1%. So, You still have the opportunity to move ahead in your career in IOS Development. Mindmajix offers Advanced IOS Development Interview Questions 2024 that helps you in cracking your interview & acquire your dream career as IOS Developer.

Top 10 Frequently Asked IOS Development Interview Questions - iPhone

  1. Which JSON framework is supported by iOS?
  2. When an app is said to be not running the state?
  3. What is the use of controller object UIApplication?
  4. What is the purpose of the UIWindow object?
  5. What is App Bundle?
  6. What are the App states? Explain them?
  7. What's the NSCoder class used for?
  8. What is a sandbox?
  9. What is dynamic?
  10. What are all the newly added frameworks iOS 4.3 to iOS 5.0?

IOS Development Interview Questions and Answers

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

Ans: 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 a real device before publishing it.

Are you interested in taking up for IOS Development Certification Training? Enroll in Free Demo on IOS Development Online Training!

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

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 an Intel-based Macintosh computer and iOS SDK.

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

Ans: The UIKit framework is used to develop the 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. Name the application thread from where UIKit classes should be used?

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

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

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

MindMajix YouTube Channel

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

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

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

Ans: 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 the foreground app.

10. Which framework delivers the event to a custom object when an app is in the foreground?

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

11. When an app is said to be not running the state?

Ans: An app is said to be in a ‘not running’ state when:

  • It is not launched.
  • It gets terminated by the system during running.

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

Ans: An app will be in an 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.

13. Give example scenarios when an application goes into InActive state?

Ans: An app can get into an 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.

14. When an app is said to be in an inactive state?

Ans: An app is said to be in the inactive state when it is running in the foreground and is receiving events.

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

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

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

Ans: Background state.

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

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

18. Assume that the system is running low on memory. What can the system do for suspended apps?

Ans: In case the system is running low on memory, the system may purge suspended apps without notice.

19. 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 the app’s delegate object.

For example: 

applicationDidBecomeActive method can be used to prepare to run as the foreground app.
The applicationDidEnterBackground method can be used to execute some code when the 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
application will terminate method is called when your app is being terminated.

20. List down the app’s state transitions when it gets launched.

Ans: Before the launch of an app, it is said to be in not running state.
When an app is launched, it moves to the active or background state, after transitioning briefly through the inactive state.

21. Who calls the main function of your 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.

22. What is the use of controller object UIApplication?

Ans: Controller object UIApplication is used without subclassing to manage the application event loop.
It coordinates other high-level app behaviors.
It works along with the app delegate object which contains app-level logic.

23. Which object is created by the UIApplicationMain function at app launch time?

Ans: The app delegate object is created by the UIApplicationMain function at app launch time. The app delegate object’s main job is to handle state transitions within the app.

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

25. What happens if the application object does not handle an event?

Ans: In such a case, the event will be dispatched to your app delegate for processing.

26. Which app-specific objects store the app’s content?

Ans: Data model objects are app-specific objects and store the app’s content. Apps can also use document objects to manage some or all of their data model objects.

27. Are document objects required for an application? What do they offer?

Ans: Document objects are not required but are very useful in grouping data that belongs in a single file or file package.

28. Which object manages the presentation of the app’s content on the screen?

Ans: View controller objects take care of the presentation of the app’s content on the screen. A view controller is used to manage a single view along with the collection of subviews. It makes its views visible by installing them in the app’s window.

29. Which is the superclass of all view controller objects?

Ans: UIViewController class. The functionality for loading views, presenting them, rotating them in response to device rotations, and several other standard system behaviors are provided by UIViewController class.

30. What is the purpose of the UIWindow object?

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

31. How do you change the content of your app in order to change the views displayed in the corresponding window?

Ans: To change the content of your app, you use a view controller to change the views displayed in the corresponding window. Remember, the window itself is never replaced.

32. Define view object.

Ans: Views along with controls are used to provide a visual representation of the app content. A view is an object that draws content in a designated rectangular area and it responds to events within that area.

33. You wish to define your custom view. Which class will be subclassed?

Ans: Custom views can be defined by subclassing UIView.

34. Apart from incorporating views and controls, what else an app can incorporate?

Ans: Apart from incorporating views and controls, an app can also incorporate Core Animation layers into its view and control hierarchies.

35. What are layer objects and what do they represent?

Ans: Layer objects are data objects which represent visual content. Layer objects are used by views to render their content. Custom layer objects can also be added to the interface to implement complex animations and other types of sophisticated visual effects.

36. How would you create your own custom view?

Ans: By Subclassing the UIView class.

37. What is App Bundle?

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

38. What fast enumeration?

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

Related Article:  iPhone Tutorials for Beginners

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

40. What's the difference between  NSArray and  NSMutableArray?

Ans: NSArray's contents can not be modified once it?s been created whereas an NSMutableArray can be modified as needed, i.e items can be added/removed from it.

41. What's 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).

42. Is a delegate retained?

Ans: No, the delegate is never retained! Ever!

43. Outline the class hierarchy for a UIButton until NSObject.

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

44. What are the App states? Explain them?

Ans:

  1. Not running State:  The app has not been launched or was running but was terminated by the system.
  2. 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.
  3. Active state: The app is running in the foreground and is receiving events. This is the normal mode for foreground apps.
  4. 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.”
  5. 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.

45. Why do we need to use @Synthesize?

Ans: We can use generated code like nonatomic, atomic, 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, the 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.

46. Multitasking support is available from which version?

Ans: iOS 4.0.

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

Ans: 256bytes.

48. If I call performSelector:withObject: after delay: – is the object retained?

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

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

Ans: When you send an object an 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 releases it at the end.

This establishes a pool for the lifetime of the task. However, this also means that any autorelease 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.)

50. What's the NSCoder class used for?

Ans: NSCoder is an abstractClass that represents a stream of data that is 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 decode objects methods in them).

51. What's an NSOperationQueue and how/would you use it?

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

52. Explain the correct way to manage Outlet's memory.

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

53. What is a sandbox?

Ans: 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. The above Figure shows the basic layout of a sandbox directory.

54. Is the delegate for a CAAnimation retained?

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

55. What is dynamic?

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

56. What happens when the following code executes?

Ans: Ball *ball = [[[[Ball alloc] init] autorelease] autorelease];
It will crash because it's added twice to the autorelease pool and when it is dequeued the autorelease pool calls release more than once.

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

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

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

59. Implement the following methods: retain, release, autorelease?

Ans:

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

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

Ans:

  • Accounts
  • CoreBluetooth
  • CoreImage
  • GLKit
  • GSS
  • NewsstandKit
  • Twitter

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

62. What is the difference between retaining & assign?

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

Join our newsletter
inbox

Stay updated with our newsletter, packed with Tutorials, Interview Questions, How-to's, Tips & Tricks, Latest Trends & Updates, and more ➤ Straight to your inbox!

Course Schedule
NameDates
IOS Development TrainingMar 23 to Apr 07View Details
IOS Development TrainingMar 26 to Apr 10View Details
IOS Development TrainingMar 30 to Apr 14View Details
IOS Development TrainingApr 02 to Apr 17View Details
Last updated: 27 Feb 2024
About Author

Ravindra Savaram is a Technical Lead at Mindmajix.com. His passion lies in writing articles on the most popular IT platforms including Machine learning, DevOps, Data Science, Artificial Intelligence, RPA, Deep Learning, and so on. You can stay up to date on all these technologies by following him on LinkedIn and Twitter.

read more
Recommended Courses

1 / 15