Book Image

Application Development in iOS 7

By : Kyle Begeman
Book Image

Application Development in iOS 7

By: Kyle Begeman

Overview of this book

Table of Contents (15 chapters)
Application Development in iOS 7
About the Author
About the Reviewers

Saving the data

We now have everything we need from the user to create a new food entry. In order to save the data, we will need to follow multiple steps so that we can access it again later in the app. The save data method we created earlier will be quite long once complete, so we will cover it piece by piece for simplicity, starting with a custom date helper method.

Getting the date string

For our application, we will be creating a .plist file that will store the food entry's name, date created, and the file path to the image. The image itself will be saved separately in the documents directory. When saving any file to the documents directory, you must specify a filename. In order to save multiple images, we need to make sure that every single image file saved has a different filename. One of the best (and most popular) ways to accomplish this is using a date.

Each device keeps track of the current date down to the millisecond. This means that at any given millisecond, the date will be completely...