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.
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.