Sams Teach Yourself Core Data for Mac® and iOS in 24 Hours, Second Edition

Book description

In just 24 sessions of one hour or less, start using Core Data to build powerful data-driven apps for iOS devices and Mac OS X computers! Using this book’s straightforward, step-by-step approach, you’ll discover how Apple’s built-in data persistence framework can help you meet any data-related requirement, from casual to enterprise-class. Beginning with the absolute basics, you’ll learn how to create data models, build interfaces, interact with users, work with data sources and table views. Every lesson builds on what you’ve already learned, giving you a rock-solid foundation for real-world success!

Step-by-step instructions carefully walk you through the most common Core Data development tasks.

Quizzes and Exercises at the end of each chapter help you test your knowledge.

Notes present interesting information related to the discussion.

Tips offer advice or show you easier ways to perform tasks.

Cautions alert you to possible problems and give you advice on how to avoid them.

Jesse Feiler is a leading expert on Apple database development. Feiler has worked with databases since the 1980s, writing about technologies that have since evolved into Core Data. His database clients have included Federal Reserve Bank of New York, Young & Rubicam, and many small and nonprofit organizations. His recent books include Data-Driven iOS Apps for iPad and iPhone with FileMaker Pro, Bento by FileMaker, and FileMaker Go; and FileMaker 12 in Depth.

Learn how to…

• Start writing database apps fast, with Xcode 4’s powerful tools and templates

• Master the Objective-C features and patterns Core Data relies upon

• Understand Core Data’s goals, components, and behavior

• Model data graphically with Xcode 4’s Data Model Editor

• Leverage the full power of Managed Objects

• Use controllers to integrate your data model with your code

• Fetch, use, and store data from any source

• Develop interfaces and features more quickly with Interface Builder

• Add navigation and control features that integrate seamlessly with Core Data

• Interact with users via popovers, segmented controls, action sheets, and tab bars

• Create table views that users can edit

• Let Xcode 4 and Core Data validate your data for you

• Use predicates to precisely select the right data

• Get ready for iCloud features to sync and move data among your iCloud-enabled devices

Category: iOS/Mac Programming

Covers: Core Data

User Level: Beginning-to-Intermediate

Table of contents

  1. Title Page
  2. Copyright Page
  3. Contents at a Glance
  4. Table of Contents
  5. About the Author
  6. Acknowledgments
  7. Want to Hear from You!
  8. Reader Services
  9. Introduction
    1. Who Should Read This Book
    2. Some Points to Keep in Mind
    3. How This Book Is Organized
  10. Part I. Getting Started with Core Data
    1. Hour 1. Introducing Xcode 4
      1. Getting to Know Xcode
      2. Goodbye “Hello, World”
      3. Hello, App Development for Mac OS X and iOS
      4. Getting Started with Xcode
      5. Using the Navigator
      6. Using Editors
      7. Working with Assistant
      8. Getting Help in an Editor Window
      9. Using Utilities—Inspectors
      10. Using Utilities—Libraries
      11. Using the Text Editor
      12. Using the Organizer Window
      13. Summary
      14. Workshop
      15. Activities
    2. Hour 2. Creating a Simple App
      1. Starting to Build an App
      2. Building the Project
      3. Exploring the App
      4. Summary
      5. Workshop
      6. Activities
    3. Hour 3. Understanding the Basic Code Structure
      1. Working with the Code
      2. Looking at Object-Oriented Programming in the Context of Objective-C
      3. Using Declared Properties
      4. Messaging in Objective-C
      5. Using Protocols and Delegates
      6. Using the Model/View/Controller Concepts
      7. Importing and Using Declarations in Files
      8. Summary
      9. Workshop
      10. Activities
  11. Part II. Using Core Data
    1. Hour 4. Getting the Big Core Data Picture
      1. Starting Out with Core Data
      2. Examining Core Data at Runtime: The Core Data Stack
      3. Working with Fetched Results
      4. Summary
      5. Workshop
      6. Activities
    2. Hour 5. Working with Data Models
      1. Making the Abstract Concrete
      2. Working with Entities
      3. Adding Attributes to Entities
      4. Linking Entities with Relationships
      5. Keeping Track of Your Data in Files and Documents
      6. Summary
      7. Workshop
      8. Activities
    3. Hour 6. Working with the Core Data Model Editor
      1. Moving the Data Model from Paper to Xcode and the Core Data Model Editor
      2. Adding Entities to the Data Model
      3. Choosing the Editor Style
      4. Adding Relationships to a Data Model
      5. Summary
      6. Workshop
      7. Activities
    4. Hour 7. What Managed Objects Can Do
      1. Using Managed Objects
      2. Deciding Whether to Override NSManagedObject
      3. Overriding NSManagedObject
      4. Implementing Transformation in an NSManagedObject Subclass
      5. Summary
      6. Workshop
      7. Activities
    5. Hour 8. Controllers: Integrating the Data Model with Your Code
      1. Looking Inside Model/View/Controller
      2. Integrating Views and Data on Mac OS
      3. Integrating Views and Data on iOS
      4. Summary
      5. Workshop
      6. Activities
    6. Hour 9. Fetching Data
      1. Choosing the Core Data Architecture
      2. Exploring the Core Data Fetching Process
      3. Using Managed Object Contexts
      4. Creating and Using a Fetch Request
      5. Stopping the Action to Add New Data
      6. Optimizing Interfaces for Core Data
      7. Taking Advantage of Mac OS Interface Features for Core Data
      8. Taking Advantage of iOS Interface Features for Core Data
      9. Summary
      10. Workshop
      11. Activities
    7. Hour 10. Working with Predicates and Sorting
      1. Understanding Predicates
      2. Constructing Predicates
      3. Creating a Fetch Request and Predicate with Xcode
      4. Sorting Data
      5. Summary
      6. Workshop
      7. Activities
  12. Part III. Developing the Core Data Interface
    1. Hour 11. Finding Your Way Around the Interface Builder Editor: The Graphics Story
      1. Starting to Work with the Interface Builder Editor in Xcode
      2. Creating a Universal App and Interacting with the Device
      3. Working with the Canvas
      4. Summary
      5. Workshop
      6. Activities
    2. Hour 12. Finding Your Way Around the Interface Builder Editor: The Code Story
      1. Using the Connections Inspector
      2. Using IBOutlets for Data Elements
      3. Summary
      4. Workshop
      5. Activities
    3. Hour 13. Control-Dragging Your Way to Code
      1. Repurposing the Master-Detail Application Template
      2. Adding New Fields as IBOutlets
      3. Summary
      4. Workshop
      5. Activities
    4. Hour 14. Working with Storyboards and Swapping Views
      1. Creating a Project with a Storyboard
      2. Swapping Views on iOS Devices
      3. Swapping Detail Views (the Old Way)
      4. Understanding the Storyboard Concept
      5. Looking at the Estimator Storyboard and Code
      6. Creating a Storyboard
      7. Summary
      8. Q&A
      9. Workshop
      10. Activities
  13. Part IV. Building the Core Data Code
    1. Hour 15. Saving Data with a Navigation Interface
      1. Using a Navigation Interface to Edit and Save Data
      2. Starting from the Master-Detail Template
      3. Using the Debugger to Watch the Action
      4. Adding a Managed Object
      5. Moving and Saving Data
      6. Cleaning Up the Interface
      7. Summary
      8. Workshop
      9. Activities
    2. Hour 16. Using Split Views on iPad
      1. Moving to the iPad
      2. Implementing the Second Interface
      3. Changing the Data Update and Saving Code
      4. Summary
      5. Workshop
      6. Activities
    3. Hour 17. Structuring Apps for Core Data, Documents, and Shoeboxes
      1. Looking at Apps from the Core Data Point of View: The Role of Documents
      2. Exploring App Structure for Documents, Mac OS, and iOS
      3. Moving Data Models
      4. Moving a Data Model from One Project to Another
      5. Summary
      6. Workshop
      7. Activities
    4. Hour 18. Validating Data
      1. Using Validation Rules in the Data Model
      2. Setting Up Rules in Your Data Model
      3. Entering Data into the Interface and Moving It to the Data Model (and Vice Versa)
      4. Creating Subclasses of NSManagedObject for Your Entities
      5. Summary
      6. Workshop
      7. Activities
  14. Part V. Managing Data and Interfaces
    1. Hour 19. Using UITableView on iOS
      1. Working with Table Views and iOS, Mac OS, and Core Data
      2. Comparing Interfaces: Settings on iOS and System Preferences on Mac OS
      3. Using UITableView Without Core Data
      4. Using UITableView with Core Data
      5. Summary
      6. Q&A
      7. Workshop
      8. Activities
    2. Hour 20. Using NSTableView on Mac OS
      1. Exploring the New NSTableView Features
      2. Building an NSTableView App
      3. Summary
      4. Q&A
      5. Workshop
      6. Activities
    3. Hour 21. Rearranging Table Rows on iOS
      1. Handling the Ordering of Table Rows
      2. Allowing a Table Row to Be Moved
      3. Doing the Move
      4. Summary
      5. Q&A
      6. Workshop
      7. Activities
    4. Hour 22. Managing Validation
      1. Validation for Free
      2. Validation on Mac OS
      3. Programming Validation for iOS or Mac OS
      4. Summary
      5. Workshop
      6. Activities
    5. Hour 23. Interacting with Users
      1. Choosing an Editing Interface
      2. Communicating with Users
      3. Using Sheets and Modal Windows on Mac OS
      4. Summary
      5. Workshop
      6. Activities
    6. Hour 24. Migrating Data Models
      1. Introducing the Core Data Migration Continuum
      2. Managing Data Model Migration
      3. Working with Data Model Versions
      4. Using Automatic Lightweight Migration
      5. Looking at a Mapping Model Overview
      6. Summary
      7. Workshop
      8. Activities
  15. Appendix A. What’s Old in Core Data, Cocoa, Xcode, and Objective-C
    1. Declared Properties
    2. Required and Optional Methods in Protocols
    3. Storyboards in Interface Builder
    4. Ordered Relationships
  16. Index

Product information

  • Title: Sams Teach Yourself Core Data for Mac® and iOS in 24 Hours, Second Edition
  • Author(s):
  • Release date: June 2012
  • Publisher(s): Sams
  • ISBN: 9780133105100