Copying and Modification

You may have expected to see 99 printed in the console because in the pulsing example, you were able to successfully modify self.taxiWidth.constant. This has to do with how the block’s execution stack is created. Figure 13-1 shows that the stack has a read-only (italicized) copy of each variable. The values are frozen at the time the block is created.

Image

Figure 13-1 Block context variables

Although the block’s copy of self is not modifiable, the value is still the address for the same aboutViewController object. The properties can still be changed, as can any part of those properties.

For the 99 example, aNumber is not a ...

Get Learning iOS Development: A Hands-on Guide to the Fundamentals of iOS Programming 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.