Skip to content
This repository has been archived by the owner on Mar 9, 2022. It is now read-only.

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

Open
mdfw opened this issue Jul 9, 2013 · 2 comments
Open

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

mdfw opened this issue Jul 9, 2013 · 2 comments

Comments

@mdfw
Copy link

mdfw commented Jul 9, 2013

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];
}
@snej
Copy link
Contributor

snej commented Jul 9, 2013

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.

@mdfw
Copy link
Author

mdfw commented Jul 10, 2013

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants