Ben Kennedy
unread,Dec 10, 2015, 4:06:07 PM12/10/15Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Sign in to report message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to mobile-c...@googlegroups.com
Hey folks,
Let's say I wish to create a CBLModel subclass for a CBLDocument representing this structure:
{
"antelope" : {
"alpha" : "one",
"beta" : "two"
},
"edibles" : {
"meat" : "flesh",
"leaves" : "vegetables"
},
"beer" : "flanders sour ale"
}
In my client code, I want to be able to e.g. fetch vegetables as NSString *vegetables = someModel.edibles.leaves; .
While it is obvious from the documentation that I can create a CBLModel subclass with a @property NSString *beer, it is not clear to me how to describe the first two dictionaries.
It strikes me that I might be advised to create AntelopeModel and EdiblesModel subclasses of MYDynamicObject, and then declare such properties in my CBLModel subclass. This does not work, though, because the linker can't find MYDynamicObject when I build. (Obviously these subclasses cannot descend from CBLModel, since they are not documents themselves).
What is the correct way to do this?
Next, I have an ancillary question: is it possible, or even valid, to acquire a CBLModel object representing a specific CBLRevision of its CBLDocument?
When the time comes to resolve conflicts between versions of my document, I wish to be able to call its synthesized properties in my business logic (much as I illustrated above with the vegetables). However, since conflict resolution deals in CBLRevisions, it is not clear to me how this is possible. It appears I am left to traverse the revision.properties array directly in this case, which makes the overall value of CBLModel rather dubious, if I end up having to write everything two ways.
Do I overlook something?
thanks,
-ben