On Feb 14, 2014, at 1:05 PM, Alan McKean 
<[email protected]<mailto:[email protected]>> wrote:

But my CBLModel subclasses implement accessors to get and set the 
decryptedDictionary values. So the property names don't get registered as 
having changed. Is there a good way to tell the CBLModel that a given property 
has changed?

This doesn't sound like a good direction to go in -- you're working against the 
grain of CBLModel. Trying to make this work will get more and more hacky.

Instead, try what I suggested earlier -- decode the document properties on 
their way into the model. There are two CBLModel methods that access 
_document.properties. Change those into calls to a new overrideable method, 
call it -documentProperties, that by default returns _document.properties.

So change both occurrences of
    NSMutableDictionary* properties = [_document.properties mutableCopy];
to
    NSMutableDictionary* properties = self.documentProperties;

and implement the method like this:
- (NSMutableDictionary*) documentProperties {
return [_document.properties mutableCopy];
}

Then you can override -documentProperties to decrypt the properties and return 
those. (I made the method return an NSMutableDictionary to reduce the amount of 
copying going on; if you're assembling a dictionary you'll probably have a 
mutable instance already, and both the callers want a mutable dictionary 
anyway.)

If this works for you, I can add it into CBLModel, especially if you send a 
pull request with a unit test :)

--Jens

-- 
You received this message because you are subscribed to the Google Groups 
"Couchbase Mobile" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/mobile-couchbase/ACD6E2EA-CF16-40AB-990D-7B94BAC2AB52%40couchbase.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to