Chapter 4
iOS Application Basics
In Lesson 1, you created your first iOS application by dragging a few visual elements from the Object library onto your application’s .xib file. For an app to do something useful, though, it must be able to handle user interaction. This was something missing from the HelloiOS app created in Lesson 1. In this lesson you learn some basic concepts involved in iOS application programming, and how to add interactivity to your apps.
iOS programming is based on an event-driven model and is all about writing code to respond to one or more events. The device generates these events every time the user does something with the application. For instance, if the user taps a button, an appropriate “touch” event is generated by the device and forwarded to the application.
Direct user interaction, although the most common reason for events, isn’t the only one. For instance, events are generated when the phone is receiving a call, when a file has successfully downloaded from a server, and so on. Practically anything that happens on an iOS device ends up generating one or more events. When an event is generated, the operating system looks into your program to see if a method in one of your classes should be notified.
The key to iOS programming lies in knowing what these events are, and how to set your methods to be called when one of these events occurs. Figure 4-1 shows a simplified version of the sequence of events that occurs between the launch and termination ...
Get iPhone and iPad App 24-Hour Trainer now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.