Summary

This chapter opened with an overview of background fetch, how it works, and how it benefits your users. You also learned about the prerequisites and best practices for this feature. After establishing this basic understanding, you learned how background fetch works in concert with your application. Then, we continued to implement the required permissions and asked iOS to wake up the MustC application periodically so we could update the movies' ratings.

Once you did this, you had to refactor a good portion of the application to accommodate the new feature. It's important to be able to recognize scenarios where refactoring is a good idea, especially if it enables the smooth implementation of a feature later on. It also demonstrates that you don't have to think about every possible scenario for your code every time you implement a feature. After refactoring the application, you were finally able to implement background-fetching behavior. To do this, you quickly glanced over dispatch groups and how they allow you to group an arbitrary amount of asynchronous work togetherĀ andĀ be notified when all of the tasks in a group are completed.

Now that you know how to fetch data from the network, store it locally, and update it in the background, wouldn't it be great if you could sync data across devices and automatically update it in the background as soon as new data is available? That's precisely what the next chapter is all about!