Chapter 13: Controlling Multitasking
There are two broad meanings of multitasking in iOS. First, it refers to running multiple applications at the same time by allowing one or more applications to run “in the background.” Second, it refers to when a single application runs multiple operations simultaneously. Both are important parts of many iOS applications, and this chapter discusses both.
You discover the best practices for multitasking and the major iOS frameworks for multitasking: run loops, threads, operations, and Grand Central Dispatch (GCD). If you’re familiar with thread-based multitasking from other platforms, you find out how to reduce your reliance on explicit threads and make the best use of iOS’s frameworks that avoid threads or handle threading automatically. Perhaps most importantly, you learn how to give your users the illusion of multitasking without wasting system resources.
In this chapter, I assume that you understand the basics of running tasks in the background and that you’re familiar with
beginBackgroundTaskWithExpirationHandler:, registering an app as location aware, and similar background issues. If you need information about the fundamental technologies, see “Executing Code in the Background” in the iOS Application Programming Guide (
Similarly, this chapter assumes that you have at least a passing familiarity with operation queues and Grand Central Dispatch, though you may never have used them in real code. If you’ve never heard ...