The main tool you use to write code for an iPhone application is the Xcode text editor. Apple has gone out of its way to make the text editor as user-friendly as possible, as evidenced by the following list of (quite convenient) features:
✓ Code Sense: As you type code, you can have the Editor help by inserting text that completes the name of whatever Xcode thinks you’re going to enter.
Using Code Sense can be really useful, especially if you’re like me and forget exactly what the arguments are for a function. When Code Sense is active (it is by default), Xcode uses the text you typed, as well as the context within which you typed it, to provide suggestions for completing what it thinks you’re going to type. You can accept suggestions by pressing Tab or Return. You may also display a list of completions by pressing Escape.
✓ Code Folding: With code folding, you can collapse code that you’re not working on and display only the code that requires your attention. You do this by clicking in the column to the left of the code you want to hide.
✓ Switching between header and implementation windows: On the
Toolbar above the code editor, you click the last icon before the lock to switch from. h to. m (header and implementation), and vice versa. While the header lets you see the class’s instance variables and method declarations, you find your actual code in the implementation file. If you look in the Groups & Files pane of the project window, you can see the separate .h and. m files for the four classes we have started with.
✓ Launching a file in a separate window: Double-click the filename to launch the file in a new window. This enables you folks with big monitors, or multiple monitors, to look at more than one file at a time. You could, for example, look at the method of one class and the method it invokes in the same, or even a different class.


Congratulations — you have just gone through the "Classic Comics" version of another several hundred pages of Apple documentation, reference manuals, and how-to guides.
Various events besides termination can interrupt your application to allow the user to respond — for example, incoming phone calls, SMS messages, calendar alerts, or the user pressing the Sleep button on an iPhone. Such interruptions may only be temporary. If the user chooses to ignore an interruption, your application continues running as before. If the user decides to answer the phone or reply to an SMS message, however, your application will be terminated.
Launch, initialize, process, terminate, launch, initialize, process, terminate. . . it has a nice rhythm to it, doesn’t it? And those are the four major stages of the application’s life cycle. But life isn’t simple — and neither is runtime. To mix things up a bit, your application will also have to come to terms with interruptions and memory management.
Getting stuff to (safely) shut down is another application delegate responsibility. To handle termination, the application delegate implements the delegate method applicationWillTerminate: to save any unsaved data or key application state (where the user is in the application — the current view and stuff like that) to disk. (Okay, I know, the disk in the iPhone is not really a disk; it’s a solid state drive that Apple calls a disk, but if it calls it that, I probably should, too, just so I don’t confuse too many people.). You can also use this method to perform additional cleanup operations, such as deleting temporary files.
After a user launches your application, the functionality provided in the UIKit framework manages most of the application’s infrastructure. Part of the initialization process mentioned in the previous section involves setting up the main run loop and event handling code, which is the responsibility of
The next step is for the UIApplication to send the ReturnMeToApp Delegate applicationDidFinishLaunching: message. Step 5 in Figure 6-6 represents what happens when the applicationDidFinish Launching: method is invoked.