Creating BNRImageStore

The image store will hold the pictures the user takes. In Chapter 18, you will have instances of BNRItem write out their instance variables to a file, which will then be read in when the application starts. However, because images tend to be very large, it is a good idea to keep them separate from other data. The image store will fetch and cache the images as they are needed. It will also be able to flush the cache if the device runs low on memory.

Create a new NSObject subclass called BNRImageStore. Open BNRImageStore.h and create its interface:

#​i​m​p​o​r​t​ ​<​F​o​u​n​d​a​t​i​o​n​/​F​o​u​n​d​a​t​i​o​n​.​h​>​

@​i​n​t​e​r​f​a​c​e​ ​B​N​R​I​m​a​g​e​S​t​o​r​e​ ​:​ ​N​S​O​b​j​e​c​t​
 +​ ​(​i​n​s​t​a​n​c​e​t​y​p​e​)​s​h​a​r​e​d​S​t​o​r​e​;​ ...

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