O'Reilly logo

iOS Programming: The Big Nerd Ranch Guide by Joe Conway, Aaron Hillegass

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

Writing to the Filesystem with NSData

Our archiving in Homepwner saves and loads the imageKey for each BNRItem, but what about the images themselves? Let’s extend the image store to save images as they are added and fetch them as they are needed.

The images for BNRItem instances are created by user interaction and are only stored within the application. Therefore, the Documents directory is the best place to store them. You can use the image key generated when the user takes a picture to name the image in the filesystem.

Open BNRImageStore.h and add a new method declaration.

-​ ​(​N​S​S​t​r​i​n​g​ ​*​)​i​m​a​g​e​P​a​t​h​F​o​r​K​e​y​:​(​N​S​S​t​r​i​n​g​ ​*​)​k​e​y​;​

Implement imagePathForKey: in BNRImageStore.m to create a path in the documents ...

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