Writing to the Filesystem with Data
Your archiving in Homepwner saves and loads the itemKey for each Item, but what about the images? At the moment, they are lost when the app enters the background state. In this section, you will extend the image store to save images as they are added and fetch them as they are needed.
The images for Item instances should also be stored in the Documents directory. You can use the image key generated when the user takes a picture to name the image in the filesystem.
Implement a new method in ImageStore.swift named imageURL(forKey:) to create a URL in the documents directory using a given key.
func imageURL(forKey key: String) -> URL { let documentsDirectories = FileManager.default.urls(for: ...
Get iOS Programming: The Big Nerd Ranch Guide, 6th Edition 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.