Beginning Core Data with RubyMotion
Minimum price
Minimum paid price

Beginning Core Data with RubyMotion

About the Book

Core Data programming is hard. Apple warn as much in their document Core Data Core Competencies, "Important: Core Data is an advanced technology that is not required for creating simple applications". That doesn't sound so severe perhaps but it does contrast greatly with the rest of the developer documentation that seems to suggest that iOS/OSX programming is made easy by all the frameworks and widgets ready for us to customise and use in our applications.

Compared to many other Apple frameworks, Core Data seems to be considerably less developer-friendly. Compare it then to the elegance of the RubyMotion framework and the constrast becomes more stark. How are we to define our models, relationships and migrations without the tools that Xcode provides?

In this book we set out exactly how you can create Core Data-powered apps using RubyMotion that are ready for the app store, including preparing for the future by learning the ins and outs of schema and data migrations. Below is an outline of the topics we cover:

  • An Overview of the Core Data architecture
  • Setting up the Core Data stack in RubyMotion
  • Modelling your data without Xcode
  • Managing Schema Migrations
  • Handling Data (Heavyweight) Migrations
  • Adding undo/redo Management to your app
  • Tips to get unstuck when faced with common Core Data issues

All sample code is available on GitHub.

  • Share this book

About the Author

Stefan Magnuson, PhD
Stefan Magnuson, PhD

Computer scientist and software developer by trade, I've worked on systems ranging from the very small (embedded) to the reasonably large (high-throughput data processing for mobile networks), published papers on Evolutionary Neural Networks and am actively involved in the world of web startups in both the UK and Japan. I have three apps in the iOS app store and am interested in the potential for RubyMotion to make future app development easier, faster and more enjoyable for all of us.

Table of Contents

  • 1. Introduction
    • Core Data
    • RubyMotion
    • Core Data & RubyMotion
    • Technical Notes and Bugs
    • Structure of this Book
  • 2. Diving into Core Data
    • App Structure
    • The Core Data Stack
    • Setting up our Entities
    • Setting up the Stack
    • Creating, Reading, Updating and Deleting Records
    • Searching and Sorting
    • Wrapping Up
  • 3. Core Data Models Without Xcode
    • Getting Started
    • Defining a Model
    • A First Migration
    • Second Migration: Adding a Related Model
    • Testing Both Migrations Together
    • Saving and Retrieving Records
    • Wrapping Up
  • 4. Core Data Query
    • Getting Started
    • Migrations
    • Displaying our Tasks
    • Adding a Relationship
    • Performing Aggregate Queries
  • 5. Case Study: Core Data Books
    • The Model
    • The Core Data Stack
    • The Root View Controller
    • Responding to Changes
    • Implementing the Detail View Controller
    • Adding New Books
    • Adding Undo and Redo Capabilities
    • Wrapping Up
  • 6. Data Migrations
    • Overview
    • Getting Started
    • Setting up the Migration Process
    • The First Schema Migration
    • The Data Migration
    • The Final Schema Migration
    • Wrapping Up
  • 7. Tips & Troubleshooting
    • Debugging Core Data
    • Interacting With Views in the Console
    • Uninitialized constant NSSQLiteStoreType
    • Undefined method `viewWillAppear’
    • Other Errors and Crashes

Causes Supported


Watsi is a global crowdfunding platform for healthcare that enables anyone to donate as little as $5 to directly fund life-changing medical care for people in need. 100% of every donation funds medical care and we are dedicated to complete transparency.

Watsi ( is the first global crowdfunding platform for healthcare, enabling anyone to directly fund low-cost, high-impact medical care for people in need. 100% of every donation on Watsi’s platform directly funds medical care for patients, the organization does not take a cut for its operations. Since launching in August of 2012, Watsi has funded medical care for more than 700 people in 16 countries.

The Leanpub 60 Day 100% Happiness Guarantee

Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.

Now, this is technically risky for us, since you'll have the book or course files either way. But we're so confident in our products and services, and in our authors and readers, that we're happy to offer a full money back guarantee for everything we sell.

You can only find out how good something is by trying it, and because of our 100% money back guarantee there's literally no risk to do so!

So, there's no reason not to click the Add to Cart button, is there?

See full terms...

80% Royalties. Earn $16 on a $20 book.

We pay 80% royalties. That's not a typo: you earn $16 on a $20 sale. If we sell 5000 non-refunded copies of your book or course for $20, you'll earn $80,000.

(Yes, some authors have already earned much more than that on Leanpub.)

In fact, authors have earnedover $13 millionwriting, publishing and selling on Leanpub.

Learn more about writing on Leanpub

Free Updates. DRM Free.

If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).

Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.

Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.

Learn more about Leanpub's ebook formats and where to read them

Write and Publish on Leanpub

You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses!

Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks.

Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. (Or, if you are producing your ebook your own way, you can even upload your own PDF and/or EPUB files and then publish with one click!) It really is that easy.

Learn more about writing on Leanpub