Home > Articles > Programming > General Programming/Other Languages

iOS Components and Frameworks: Getting Up and Running with Core Data

  • Print
  • + Share This
This chapter describes how to set up a project to use Core Data and illustrates how to implement several common use cases with the sample app. It covers how to set up your data model, how to populate some starting data, and how to display data in a table using a fetched results controller. This chapter also demonstrates how to add, edit, and delete data, how to fetch data, and how to use predicates to fetch specific data. With this knowledge, you will have a good foundation for implementing Core Data quickly in your apps.
This chapter is from the book

At first glance, Core Data can look difficult and overwhelming. There are several books devoted solely to Core Data, and the official Apple documentation is lengthy and challenging to get through since it covers the entire breadth and depth of the topic. Most apps do not require all the features that Core Data has to offer. The goal of this chapter is to get you up and running with the most common Core Data features that apps need.

Sample App

The sample app for this chapter is called MyMovies. It is a Core Data–based app that will keep track of all your physical media movies and, if you have loaned a movie to someone, who you loaned it to and when (as shown in Figure 13.1).

Figure 13.1

Figure 13.1 Sample App: Movies tab.

The sample app has three tabs: Movies, Friends, and Shared Movies. The Movies tab shows the whole list of movies that the user has added and tracked in a table view. There are two sections in the table view demonstrating how data can be segregated with a fetched results controller. Users can add new movies from this tab, and can edit existing movies. The Friends tab lists the friends set up to share movies with, shows which friends have borrowed movies, and allows the user to add and edit friends. The Shared Movies tab displays which movies have currently been shared with friends.

  • + Share This
  • 🔖 Save To Your Account