CouchCocoa is a new Objective-C API for CouchDB on iOS and Mac OS. It’s 
“medium-level”, in that:

• It doesn't require knowledge of the HTTP API, only of CouchDB's architecture, 
so you won't have to remember special paths or URL query parameters.
• But it doesn't provide a full-fledged model layer like CoreData or 
ActiveRecord. You're still working with CouchDB documents as, basically, 
NSDictionaries, and you'll need your own mapping between those and your app's 
object model.
• It usually provides both high-level and low-level ways to do the same thing. 
So you can call CouchDocument’s -resolveConflictingRevisions: method, or if 
you’re a REST jockey you can assemble your own JSON data and call -POST: 
yourself.

A key feature is that it provides document change notifications, driven by the 
_changes feed, and filters out local changes made by your app from external 
ones made by other apps or by replication. Thus you can easily detect when 
external changes are made, and check for conflicts and update your UI.

Speaking of conflicts, the API provides easy access to a document’s revision 
history (via CouchRevision objects) and lets you compare the conflicting 
revisions and choose which properties should be in the resolved document.

There are some experimental classes (part of the Mac demo apps) that interface 
CouchDB views to Cocoa bindings, which lets you do a lot of the work of 
building a Mac app entirely in Interface Builder, with very little coding. 
(Unfortunately iOS doesn’t support bindings yet.)

[We have an iOS demo app using CouchCocoa almost ready, a modified version of 
the one in the iOS-Couchbase repo. Chris will have it up ASAP.]

The code is roughly at alpha level, by which I mean that it’s working, and 
suitable for people to start development with; but on the other hand you should 
expect bugs and limitations, and future API changes.

I’m excited to be developing this as part of my day job at Couchbase. This 
open-source framework will be a supported part of the Mobile Couchbase product. 
But we’re not positioning it as the One True Way to use Couchbase on iOS and 
Mac OS, any more than CouchRest is the One True Way on Ruby. You can of course 
still use Trundle, or roll your own interface on top of NSURLConnection. But we 
want to make CouchCocoa easy as powerful and easy to use as we can, to help you 
build amazing applications. And of course, it’s open source, and we welcome 
your contributions to it.

Repo & source code: https://github.com/couchbaselabs/CouchCocoa
Example snippets: 
https://github.com/couchbaselabs/CouchCocoa/wiki/Example-Snippets
API docs: http://couchbaselabs.github.com/CouchCocoa/docs/

—Jens

Reply via email to