Graphics Programs Reference
In-Depth Information
You can capture any kind of variable, including a pointer to an object. This is useful be-
cause you can send a message to an object that you have a pointer to in the enclosing
scope. Let's try this out.
In every iOS application, there is a
main operation queue
. When you add an operation to
this queue, it is essentially queued up as the next event in the run loop (
Figure 27.4
).
Figure 27.4 NSOperationQueue
A block can be an operation, so you can add a block to the main operation queue, and it
will execute on the next cycle of the run loop. A block that can be added to the operation
queue must return no value and take no arguments. (You can find more information in the
documentation for
NSOperationQueue
).
In
BNRAppDelegate.m
, edit
applica-
tion:didFinishLaunchingWithOptions:
to add a block to the main operation
queue that will send
computeWithValue:andValue:
to the
equation
when ex-
ecuted.
[executor setEquation:^int(int x, int y) {
int sum = x + 2;
return multiplier * (sum + y);
}];