Mac OS X Reference Library Apple Developer
Search

Introduction to NSPersistentDocument Core Data Tutorial

This tutorial takes you through the steps of building a simple Core Data–based application using NSPersistentDocument and Cocoa bindings. NSPersistentDocument is a subclass of NSDocument that integrates with the Core Data framework. You will find this tutorial useful if you’re using the Core Data framework to create a document-based application.

The task goal of this tutorial is to create a document-based application that allows a user to display and modify information about a department, employees in the department, and managerial relationships between the employees.

Important: This tutorial is targeted at Mac¬†OS¬†X¬†v10.5 and later. If you‚Äôre targeting Mac¬†OS¬†X¬†v10.4, see NSPersistentDocument Core Data Tutorial for Mac¬†OS¬†X¬†v10.4.

Who Should Read This Document

You should read this document to gain an understanding of how to create a Core Data document-based application using NSPersistentDocument and Cocoa bindings. Among other concepts, you will learn how to create the project, how to customize the creation of a document, and how to localize error messages.

Important: To complete this tutorial, you must already be familiar with basic Cocoa development practices and with Cocoa bindings. This document does not repeat fundamental Cocoa programming concepts and does not provide explicit instructions for common operations (such as using Interface Builder, including establishing bindings between user interface objects and controllers). You should, for example, ensure that you understand the material presented in Cocoa Application Tutorial Using Bindings.

Organization of This Document

“Overview of the Tutorial” describes the application you will create, and the task constraints.

“Creating the Project, Model, and Interface” describes how you create a Core Data document-based project in Xcode, and how you create the data model and how you can use it to automatically create a default user interface.

“Creating a Custom Employee Class” describes how to implement a custom class for an entity.

“Adding a Department Object” describes how you add a Department object to the document, and configure the user interface appropriately.

“Copy and Paste” describes one way you can support copy and paste in a Core Data application.

“Localizing and Customizing Model Property Names and Error Messages” describes how you can localize property names and customize alert panels.

“Document Metadata” describes how you can add metadata to your document that Spotlight can extract—it also describes how you write the Spotlight importer.

“A Sheet for Creating a New Employee” describes how you can use a sheet for data entry.

See Also

Core Data Programming Guide describes functionality provided by the Core Data framework from a high-level overview to in-depth descriptions.

Core Data Utility Tutorial takes you through the steps of building a command-line utility that uses Core Data. You are strongly encouraged to complete the low-level tutorial before following this tutorial.




Last updated: 2009-02-04

Did this document help you? Yes It's good, but... Not helpful...