I think I know what the problem is. propertiesToSave gets called on any of
my CBLModel subclasses that are not encrypted. So when a model property
changes, its name gets registered as having changed. 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?
Here's an example of an accessor pair from one of my encrypted CBLModel
subclasses:
- (NSNumber *) dateOfService {
return [self.decryptedProperties objectForKey:@"dateOfService"];
}
- (void) setDateOfService:(NSNumber *)dateOfService {
[self.decryptedProperties setObject:dateOfService forKey:@"dateOfService"
];
}
On Thursday, February 13, 2014 8:25:46 PM UTC-8, Jens Alfke wrote:
>
> Overriding -save: like that isn't going to work. The two immediate
> problems I see are:
> (1) In the encrypted case you don't call the original save method, so in
> turn -didSave doesn't get called, which does some important bookkeeping
> like clearing the needsSave flag.
> (2) There are code paths, like through +saveModels:error: and
> -[CBLDatabase saveAllModels], that don't call -save: but call the internal
> method -justSave: instead, so your code won't get called.
>
> It'd be much better if you override -propertiesToSave: instead. Just call
> super, change the returned dictionary into one with the encrypted data, and
> return that.
>
> —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/2ae5b1db-34f8-478e-9598-ce2f32485009%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.