Chapter 21. Lazy Initialization Pattern
The lazy initialization pattern embodies the just-in-time philosophy of data delivery. It delays the construction of values or data structures until that data is actually needed. Lazy initialization is a popular design pattern in both Java and Objective-C. Objective-C adds another level by implementing its own lazy initialization of class structures, which you can integrate into your own classes.
Implementing the Pattern
Here's how to implement the lazy initialization pattern:
Create a private instance or private static variable that will eventually contain the data, but is initialized with a placeholder value (typically nil).
Wrap the variable in a property that provides a public getter method.
In the getter ...