Updating Core Data objects with fetched data
So far, the only thing you have stored in Core Data is movie names. You will expand this functionality by performing a lookup for a certain movie name through the movie database API. The fetched information will be used to display and store a popularity rating for the movies in the Core Data database.
A task such as this seems straightforward at first; you could come up with a flow such as the one shown in the following steps:
- The user indicates their favorite movie.
- The movie's popularity rating is fetched.
- The movie and its rating are stored in the database.
The user interface updates with the new movie. At first glance, this is a fine strategy; insert the data when you have it. However, it's important to consider that API calls are typically done asynchronously so the user interface stays responsive. More importantly, API calls can be really slow if your user doesn't have a good internet connection...