Throw away all unsaved CBLModels in one go

7 views
Skip to first unread message

Brendan Duddridge

unread,
May 23, 2018, 12:19:43 AM5/23/18
to Couchbase Mobile
Hi,

Is it possible to throw away all CBLModels that have been created? I created them in a loop, but don't want to save them if the user clicks the Cancel button.

So I don't want subsequent saveAllModels calls to save any of the objects I want to throw out.

I know there's an unsavedModels function. Do I have to manually loop through all of those and delete them all? If so, do I then save after that? Will that create revisions or just silently forget about them?

Thanks!

Brendan

Brendan Duddridge

unread,
May 23, 2018, 12:30:59 AM5/23/18
to Couchbase Mobile
To answer my own question, this seemed to have worked:


NSArray *unsavedModels = self.databaseDocument.couchDatabase.unsavedModels;

for (CBLModel *model in unsavedModels) {

[model revertChanges];

}

Reply all
Reply to author
Forward
0 new messages