O'Reilly logo

Objective-C Quick Syntax Reference by Matthew Campbell

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

CHAPTER 27

image

Background Processing

Background Processing Defined

When your program needs to do more than one thing at a time, you can use background processing. Background processing in Objective-C is done with a Foundation class called NSOperationQueue.

NSOperationQueue manages lists of operations and decides how to schedule the resources needed to run an operation. Operations are blocks of code. Operations can execute simultaneously or one at a time.

Let’s say that you want to count to 10,000 while printing this out to the log. To do this, you would code something like the following:

for (int y=0; y<=10000; y++) {    NSLog(@"y = %i", y);}

This ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required