O'Reilly logo

Pro Objective-C Design Patterns for iOS by Carlo Chung

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 21. Flyweight

Public transportation, such as buses, has been around for over a century. A lot of passengers can share the expenses of owning and operating vehicles (e.g., buses) when they all go in the same direction. There are multiple stops/stations in public transport. People just hop on and off along the route close to the place where they want to go. The expenses of getting to the place are limited to just the trip. Compared to the costs of owning a vehicle, taking public transport is a lot cheaper. That is the beauty of sharing common resources.

In object-oriented software design, sometimes sharing common objects not only saves resources but also increases performance. For instance, we need one million instances of a class for a particular ...

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