Writing to filesystem with NSData
The images for Possession instances are created by user interaction and are only stored within the application. Therefore, the Documents directory is the best place to store them. Let’s extend the image store to save images as they are added and fetch them as they are needed. You can use the image key generated when the user takes a picture to name the image in the filesystem.
In this section, you are going to copy the JPEG representation of an image into a buffer in memory. Instead of just malloc’ing a buffer, Objective-C programmers have a handy class to create, maintain, and destroy these sorts of buffers – NSData. An NSData instance holds some number of bytes of binary data, and you’re going to use NSData ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access