6

Storing Data with Core Data

WHAT'S IN THIS CHAPTER?

  • Understanding the purpose of Core Data
  • Creating a graphical Swift program for OS X
  • Inserting new records into Core Data
  • Fetching existing records from Core Data
  • Displaying Core Data records in a table view

WROX.COM CODE DOWNLOADS FOR THIS CHAPTER

You can find the wrox.com downloads for this chapter at http://www.wrox.com/go/proswift on the Download Code tab. The code for this chapter is contained in the following file:

  • Birthdays.zip

Since its introduction in OS X 10.4, Core Data has rapidly become an integral part of many OS X and iOS programs. It is rare for both Objective-C and Swift developers to encounter programs that do not use Core Data in some way. Core Data is frequently used as both a caching layer (particularly in iOS apps), as well as a way for programs to store its most important data. While Core Data is implemented in Objective-C and designed from an Objective-C mindset, working with Core Data from Swift is just as easy as working with it from Objective-C. This chapter is a primer on how you can use Swift in conjunction with Core Data to easily write data-driven programs.

This chapter assumes some familiarity with Core Data, even if you've only worked with Core Data in Objective-C. It is an introduction to Core Data from a Swift perspective and does not cover all the finer details of working with Core Data. Core Data is a robust framework with many useful features, and entire books have been written on the ...

Get Professional Swift 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.