Summary

This chapter focused on inserting and retrieving data with Core Data. You saw how you can make use of fetch requests, predicates, fetched result controllers, and notifications to fetch data.

You started out simple, by inserting a new object by writing all the boilerplate code that's involved with this. Then, you saw how you can refactor this kind of boilerplate code by using extensions; this makes your code more readable and maintainable. It's highly encouraged that you create your own extensions whenever you encounter the same kind of patterns as we did in this chapter.

Once you saw how to insert data, you learned about fetch requests and predicates. Even though these two objects aren't very complex, they are very powerful and you'll often use them when you work with Core Data.

Next, you learned how to react to database changes with NSFetchedResultsController and NotificationCenter. A fetched results controller gives you a very powerful way to subscribe to changes for a set of results. Notifications are more of a general purpose solution but our implementation makes sure that we are actually only observing a single object.

In the next chapter, Fetching and Displaying Data from the Network, we will deep dive into retrieving data from the network so we can fetch ratings for our family member's favorite movies. You'll learn how to make a network request and add its results to your database.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.227.111.208