couchbase/couchbase-lite-ios — pull request #313 by RVijay007 (2014-04-14 18:54:33+00:00)
Title: Support for NSDictionary properties and Nested CBL Models as an abstract super class to replace the CBLJSONEncoding protocol.

I have added support for a couple of items:

1.) Support for NSDictionary properties. Now, developers can use NSDictionaries as properties in CBLModel, but doesn't yet efficiently support values that are CBLModels. However, values can be CBLNestedModels.

2.) Abstract class support for CBLNestedModels, which are class models that will nest themselves into a top level CBLModel/CBLDocument instead of having to make separate documents for any new class. This way, CBLModel properties can be thought of as purely relationships to other documents, but we can nest information that should be contained within a document as such. This supports N-level depth of a document. This class should be seen as a replacement for the CBLJSONEncoding paradigm.

CBLNestedModels supports properties that have types that are JSON-compatible, the same non-JSON compatible classes as CBLModel, CBLModel, other CBLNestedModels, and NSArrays/NSDictionaries of the former types. Unlike CBLModel, all properties should be @synthesized instead of @dynamic.

Subclasses of CBLNestedModel will not need to write their own init/encode JSON methods as this is all done automatically by the superclass. While you can make multiple subclasses for CBLNestedModel, it does not support polymorphism. Nested models must contain an explicit property declaration to the concrete subclasses of CBLNestedModels they use as properties instead of an abstract superclass to get proper encoding/decoding.

Please check out [CBLNestedModelExample](https://github.com/RVijay007/CBLNestedModelExample) to see how it is used. The AppDelegate contains methods for running the test. Use CouchbaseLiteViewer to view the contents of the database to see the output. This example also illustrates a problem with the existing CBLJSONEncoding class as a separate test in AppDelegate.