CouchModel:if autosaves, dealloc does not save if needsSave #71

mdfw opened this Issue Jul 9, 2013 · 2 comments

2 participants


If the CouchModel is set up to autosave and it is dealloc'ed before the save timer hits it, changes are lost. I was making a last change to my model before freeing it. I noticed the changes were not getting PUT into the db. I added this to my subclass' dealloc() and it fixed the problem.

if (self.needsSave && self.autosaves) {
    RESTOperation* op = [self save];
    [op wait];
couchbaselabs member

This is fixed in Couchbase Lite: the CBLDatabase keeps a set of all CBLModels that have unsaved changes. This keeps them from being dealloced unsaved, and also enables a save-all-models method.

It might be worthwhile to backport this. I'm not likely to make any significant changes to CouchCocoa on my own, though.


Ok. Thanks. For the moment it's working for me just to save manually.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment