couchbase/couchbase-lite-ios — pull request #261 by mz2 (2014-02-23 16:33:47+00:00)
Title: Adds 'properties' as a @property in CBLModel_Internal

This set of changes adds a readonly @property declaration for 'properties' in the CBLModel_Internal header and implements it in CBLModel.m.

The concrete use case I have is a CBLModel subclass which can contain nested JSON encodable objects I call 'embedded model objects' (which themselves are similar to a CBLModel uniquely identified, MYDynamicObject subclasses). The properties dictionary is used to cache the non-externalized embedded model object (this kind of CBLModel subclass is also one of the reasons I requested earlier for the property type introspection functions to be made public APIs, they were also required for supporting this kind of CBLModel subclass).

The embedded object support is not included in this change set, only used to describe a use for exposing the properties dictionary to CBLModel subclasses. Another option might be exposing instead a -getCachedValueOfProperty: in CBLModel to return a value directly from the _properties dictionary.

Also, I happened to notice off-chance that -currentProperties was returning a mutable array when it is intended as an immutable copy. This is fixed in this changeset too. The API documentation entry I added for currentProperties is probably incorrect -- I did not know how to correctly describe its is probably not documented correctly here. What would be a better way to describe it?