The Flyweight pattern minimizes the amount of memory and/or processor overhead required to use objects. The advantages of object-oriented programming are sometimes outweighed by the overhead of using objects particularly when large numbers of object instances are needed at once. The Flyweight pattern enables instance sharing to reduce the number of instances needed while preserving the advantages of using objects. Classes that implement the Flyweight pattern are called “flyweights.”
Within Cocoa, flyweights are primarily used for the following three reasons:
• Flyweights encapsulate nonobject data so that the data can be used in contexts where objects are required.
• Flyweights reduce storage requirements when a large ...