More on Low-Memory Warnings

You have seen how view controllers handle low-memory warnings – they are sent the message didReceiveMemoryWarning and release their view if it is not on the screen. This is an appropriate solution to handling a low-memory warning: an object gets rid of anything it isn’t currently using and can recreate later. Objects other than view controllers may have data that they aren’t using and can recreate later. The ImageStore is such an object – when its images aren’t on the screen, it is okay to destroy them because they can be loaded from the filesystem when they’re needed again.

Whenever a low-memory warning occurs, UIApplicationDidReceiveMemoryWarningNotification is posted to the notification center. Objects that want ...

Get iOS Programming: The Big Nerd Ranch Guide, Second Edition 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.