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 the photos – the previously saved photos as well as the newly inserted ones. You need to ask Core Data for all 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 to ...
Get iOS Programming: The Big Nerd Ranch Guide, 7th 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.