On Jan 20, 2014, at 6:31 AM, paul Orsillo <
paul.o...@gmail.com> wrote:
> CBLUnsavedRevision *newRev = [tgtDoc newRevision];
> [propSet setValue:newRev forKey:@"_rev"];
This doesn't make sense. The value of a "_rev" property is a string, not a CBLUnsavedRevision object. (Remember, a document's properties are JSON, so the only types you can use are numbers, strings, NSNull, arrays and dictionaries.)
If you want to completely replace a document's properties, you can do it like this:
CBLUnsavedRevision *newRev = [tgtDoc newRevision];
newRev.userProperties = propSet;
ok = [newRev save: &error];
or a slightly better variation:
[tgtDoc update: ^(CBLUnsavedRevision* newRev) {
newRev.userProperties = propSet;
} error: &error];
The reason the second form is better is that it handles the race condition where some other thread (such as the replicator) updates the document in between the newRevision and the save, which will cause a conflict (409). The update:error: method handles this internally and starts over again.
—Jens