Open mz2 opened 11 years ago
Looks like overloading -couchDocumentChanged: in a CouchModel subclass makes it respond to only the cases 2 and 3 noted above. Something on these lines:
(void)couchDocumentChanged:(CouchDocument *)doc { // couchDocumentChanged: not declared as a public method for CouchModel so need to performSelector: it if ([super respondsToSelector:@selector(couchDocumentChanged:)]) [super performSelector:@selector(couchDocumentChanged:) withObject:doc];
// do stuff in response to a change tracker induced change, or a failed model object save
}
Is there some way to get a response to only a change tracker induced change (isolate cases 2 and 3 from each other)?
It would be great to have separate overloadable public methods similar to -didLoadFromDocument for the three cases of:
1) model being created with document. 2) change tracker induced change to a model object. 3) a failed save of a model object.
Currently all three cases result in -didLoadFromDocument: being sent to the CouchModel object affected. This is because the method -didLoadFromDocument is called by both -initWithDocument: and by -couchDocumentChanged:, which in turn is called by -CouchDocument's -notifyChanged: and the error case in CouchModel's -saveCompleted: