Updating the Data Source
One problem with the app at the moment is that fetchInterestingPhotos(completion:) only returns the newly inserted photos. Now that the application supports saving, it should return all of the photos – the previously saved photos as well as the newly inserted ones. You need to ask Core Data for all of the Photo entities, and you will accomplish this using a fetch request.
Fetch requests and predicates
To get objects back from the NSManagedObjectContext, you must prepare and execute an NSFetchRequest. After a fetch request is executed, you will get an array of all the objects that match the parameters of that request.
A fetch request needs an entity description that defines which entity you want ...
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