Wednesday November 21, 2012

Generate A Web Service On Heroku...From Core Data Models

If you’ve used services like Parse to prototype applications backed by a database in the cloud, then you might want to check out Heroku’s new article on building a web service based on a Core Data Model. It walks you through spinning up a Heroku instance that takes the managed object model file you would build in Xcode and turns it into an REST-like endpoint. Using the magic of NSIncrementalStore, you can access this web service as if it was just a local Core Data database. Use an NSFetchedResultsController like you normally would, and boom, your table view is fed from the internet.

There’s a short video demonstrating how it all works currently living at mobile.heroku.com. I see a lot of potential for prototyping. It’s possible to use this as a synchronization strategy since you can add both local and remote Core Data persistent stores and move or copy your managed objects back and forth between them. The best part is that you don’t write the server. It gets generated from your model file. Remarkable work.