Chapter 5. App Execution Flow

Web developers are accustomed to seeing their code creations—HTML, CSS, and JavaScript—interpreted by browsers from top to bottom. As a web page loads, the browser immediately begins turning whatever it can into rendered content, applying styles, precompiling JavaScript, and, depending on the page design, executing various JavaScript pieces. A script statement that runs while the page loads and relies on a function must find that function already defined in the code load order, or a script error may block all further scripts. Your code may also be dependent upon an event such as the window object’s load event, whose firing means that all of the document elements are in place. Whatever your page entails, a highly predictable sequence of events occurs during the loading stage.

When it comes to a compiled iOS app, however, source code order becomes less important. Dependencies are less about the precise order of source code files because the compiler goes through the entire project, pulling together the disparate pieces into a single application. In this chapter, you will follow the way code execution flows in the Workbench app. This experience will introduce you to some vital services within the Objective-C and Cocoa Touch environments that perform the jobs you currently associate with browser events, such as the load event. Let’s face it: an iOS app needs to do a bunch of work when it starts loading to present itself to the user. You’ll be amazed at how ...

Get Learning the iOS 4 SDK for JavaScript Programmers 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.