small medium large xlarge

Core Data in Objective-C, Third Edition: Data Storage and Management for iOS and OS X

by

Cover image for Core Data in Objective-C, Third Edition

Core Data in Objective-C, Third Edition

Data Storage and Management for iOS and OS X

by

Core Data is Apple’s data storage framework: it’s powerful, built-in, and can integrate with iCloud. Discover all of Core Data’s powerful capabilities, learn fundamental principles including thread and memory management, and add Core Data to both your iOS and OS X projects. All examples in this edition are written in Objective-C and are based on OS X El Capitan and iOS 9.

Check out Core Data in Swift here.

Customer Reviews

Marcus’s books have long been my go-to recommendation for people who want to learn about Core Data. With new information for beginners and experts alike, they are a great insight into how you should be using Core Data and the features that it offers.

- Daniel Tomlinson

Senior software engineer, Rocket Apps Ltd.

Core Data is a very powerful resource for any developer interested in iOS and OS X application development. This book does an excellent job of explaining the details of Core Data, a topic that is otherwise considered quite hard to grasp. A mustread book for anyone developing data-intensive applications.

- Ramaninder Singh Jhajj

Area Services and Development Know-Center, Austria

Marcus has a profound understanding of Core Data, and this book describes not only the basics of working with Core Data, but also how to do so in a performant manner, with explanations and examples. This is an indispensable reference, alongside Apple’s documentation, and one that will quickly make Core Data your go-to persistence mechanism. You’ll be able to deal with anything that comes up with confidence.

- Abizer Nasir

Lead developer, Jungle Candy Software Ltd.

See All Reviews

Choose Your Format(s)

  • $48.00 In Stock

    Save $15.00 on the combo pack.

  • $38.00 In Stock
  • $25.00 In Stock
  • Ebooks are DRM free.

  • Ebook delivery options.

About this Title

Skill-meter-5-8
Pages: 238
Published: 2016-06-15
Release: P2.0 (2016-08-06)
ISBN: 978-1-68050-123-0

Core Data expert Marcus Zarra walks you through a fully developed application based around the Core Data APIs. You’ll build on this application throughout the book, learning key Core Data principles such as NSPredicate, NSFetchRequest, thread management, and memory management.

Start with the basics of Core Data and learn how to use it to develop your application. Then delve deep into the API details. Explore how to get Core Data integrated into your application properly, and work with this flexible API to create convenience methods to improve your application’s maintainability. Reduce your migration difficulties, integrate your Core Data app with iCloud, and use Core Data in a queue-based environment. By the end of the book, you’ll have built a full-featured application, gained a complete understanding of Core Data, and learned how to integrate your application into the iPhone/iPad platform.

This third edition updates all examples for OS X El Capitan and iOS 9, and gets you up to speed on changes in multithreading and batch processing. There’s a new chapter on efficiently importing data from a network location, and a new discussion of how best to pre-load data into your application.


Core Data Top Five Tips
by Marcus Zarra
  • In a multi-threaded environment, always turn on the
    -com.apple.CoreData.ConcurrencyDebug 1 setting when you are running in debug mode. This will catch threading errors during development.
  • Only use one NSManagedObjectContext for your entire User Interface. The User Interface is designed to run on a single thread and therefore using additional NSManagedObjectContext instances is unnecessary and creates problems.
  • If you are using the parent/child design with Core Data, do not try and reuse child NSManagedObjectContext instances. They are cheap and meant to be thrown away after a single use.
  • Every time you ship your application with a model change, tag that commit in your version control system so that if the model accidentally gets altered you can quickly find the original.
  • Every “error” that Core Data can potentially produce is a developer preventable error. If you treat them as hard errors (with a call to abort, for example) you will be able to test for them more easily and your error handling code becomes far less complex.

What You Need

Mac OS X El Capitan and iOS 9 and a basic working knowledge of Objective-C

Contents & Extracts

  • Introduction
    • Is This Book for You?
    • What Is Core Data?
    • Online Resources
  • Building a Foundation
    • The Storyboard
    • The Recipe List
    • The Recipe Detail
    • The Edit Workflow
    • Ready for Core Data
  • Under the Hood of Core Data
    • Introducing the NSManagedObjectModel
    • Integrating with the NSPersistentStoreCoordinator
    • Adding the NSManagedObjectContext
    • Working with NSManagedObject Instances
    • Building a NSFetchRequest
    • NSSortDescriptor
    • Wrapping Up
  • iOS: NSFetchedResultsController excerpt
    • How to Use the NSFetchedResultsController
    • Under the Hood of the NSFetchedResultsController
    • Building Our Own: ZSContextWatcher
    • Wrapping Up
  • Versioning and Migration
    • Some Maintenance Before We Migrate
    • A Simple Migration
    • The Difference Between Light and Heavy Migrations
    • A Heavy/Manual Migration
    • Fundamentals of Core Data Versioning
    • Progressive Data Migration (An Academic Exercise)
    • Wrapping Up
  • Performance Tuning
    • Persistent Store Types
    • Optimizing Your Data Model
    • Fetching
    • Faulting
    • Access Patterns
    • Wrapping Up
  • Threading excerpt
    • Threading and Core Data
    • Working on the Main Queue
    • Working off the Main Queue
    • Interqueue Communication
    • Parent/Child NSManagedObjectContext Design
    • Export Operation
    • Import Operation
    • Asynchronous Saving
    • Debug Concurrency Checking
    • Wrapping Up
  • Bulk Changes excerpt
    • Running with Scissors
    • Doing Bulk Updates
    • Notifying the Application of Changes
    • Bulk Deletes
    • Things to Consider When Using the Bulk Change APIs
    • Wrapping Up
  • Using Core Data with iCloud
    • Introducing the UIManagedDocument
    • Direct NSManagedObjectContext to iCloud
    • Consuming Changes from iCloud
    • Under the Hood
    • Migrating an Existing Application
    • Desktop iCloud Integration
    • Issues with Data Quantities
    • Sharing Data Between iOS and OS X
    • Wrapping Up
  • Adding a Desktop Foundation
    • Our Application
    • Our Application Design
    • Sharing the Data Model
    • Building the Controller Layer
    • Building the User Interface
    • Adding a Splash of Code
    • Wrapping Up
  • OS X: Bindings, KVC, and KVO
    • Key Value Coding
    • Key Value Observing
    • Cocoa Bindings and Core Data
    • Other Interface Elements That Use KVO, KVC, and Core Data
    • Wrapping Up
  • Spotlight, Quick Look, and Core Data
    • Integrating with Spotlight
    • Integrating with Quick Look
    • Putting It All Together
    • Wrapping Up
  • Dynamic Parameters
    • Building the Xcode Example Project
    • The DocumentPreferences Object
    • Using Document Prefences
    • Wrapping Up

Author

Marcus S. Zarra has spoken at numerous conferences around the globe and has taught Objective-C at top U.S. colleges. Marcus has been developing iOS applications since day one. Outside of Apple, no one has been working with Core Data longer or on more applications.