diff --git a/Objective-C/CBLDatabase.mm b/Objective-C/CBLDatabase.mm index 1f29d6ac3..5c200f2e4 100644 --- a/Objective-C/CBLDatabase.mm +++ b/Objective-C/CBLDatabase.mm @@ -1122,13 +1122,12 @@ - (void) postDatabaseChanged { const uint32_t kMaxChanges = 100u; C4DatabaseChange changes[kMaxChanges]; bool external = false; - uint32_t nChanges = 0u; + C4CollectionObservation obs = {}; NSMutableArray* docIDs = [NSMutableArray new]; do { // Read changes in batches of kMaxChanges: - bool newExternal; - nChanges = c4dbobs_getChanges(_dbObs, changes, kMaxChanges, &newExternal); - if (nChanges == 0 || external != newExternal || docIDs.count > 1000) { + obs = c4dbobs_getChanges(_dbObs, changes, kMaxChanges); + if (obs.numChanges == 0 || external != obs.external || docIDs.count > 1000) { if(docIDs.count > 0) { // TODO: Remove https://issues.couchbase.com/browse/CBL-3206 #pragma clang diagnostic push @@ -1137,19 +1136,19 @@ - (void) postDatabaseChanged { [_dbChangeNotifier postChange: [[CBLDatabaseChange alloc] initWithDatabase: self documentIDs: docIDs - isExternal: external] ]; + isExternal: external]]; #pragma clang diagnostic pop docIDs = [NSMutableArray new]; } } - external = newExternal; - for(uint32_t i = 0; i < nChanges; i++) { + external = obs.external; + for(uint32_t i = 0; i < obs.numChanges; i++) { NSString *docID =slice2string(changes[i].docID); [docIDs addObject: docID]; } - c4dbobs_releaseChanges(changes, nChanges); - } while(nChanges > 0); + c4dbobs_releaseChanges(changes, obs.numChanges); + } while(obs.numChanges > 0); } } diff --git a/Objective-C/Internal/CBLDocumentChangeNotifier.mm b/Objective-C/Internal/CBLDocumentChangeNotifier.mm index f7542f61c..11841120f 100644 --- a/Objective-C/Internal/CBLDocumentChangeNotifier.mm +++ b/Objective-C/Internal/CBLDocumentChangeNotifier.mm @@ -41,8 +41,8 @@ - (instancetype) initWithDatabase: (CBLDatabase*)db return self; } -static void docObserverCallback(C4DocumentObserver* obs, C4Slice docID, C4SequenceNumber seq, - void *context) +static void docObserverCallback(C4DocumentObserver* obs, C4Collection* collection, + C4Slice docID, C4SequenceNumber seq, void *context) { [(__bridge CBLDocumentChangeNotifier*)context postChange]; }