Documentation error in database notifications section

23 views
Skip to first unread message

Billy Bain

unread,
Jul 3, 2014, 9:21:53 AM7/3/14
to mobile-c...@googlegroups.com
This section in the documentation is incorrect. 


[[NSNotificationCenter defaultCenter] addObserverForName: kCBLDatabaseChangeNotification
            object: myDatabase
             queue: nil
        usingBlock: ^(NSNotification *n) {
            CBLDatabaseChange* change = n.object;
            NSLog(@"Document '%@' changed.", change.documentID);
        }
];

The comment for kCBLDatabaseChangeNotification states the following. (thanks for that!)

/** This notification is posted by a CBLDatabase in response to document changes.
    The notification's userInfo dictionary's "changes" key contains an NSArray of
    CBLDatabaseChange objects that describe the revisions that were added. */

A correct implementation for the block use the array to access changes.

    NSArray *changes = [n.userInfo valueForKey:@"changes"];
    for (CBLDatabaseChange *change in changes) {
        NSLog(@"Document '%@' changed.", change.documentID);
    }

Jens Alfke

unread,
Jul 3, 2014, 1:33:27 PM7/3/14
to mobile-c...@googlegroups.com

On Jul 3, 2014, at 6:21 AM, Billy Bain <billyb...@gmail.com> wrote:

This section in the documentation is incorrect. 

Thanks — we fixed that example last week, but the updated docs haven’t been pushed to the server yet. I’ll go find out why not.

—Jens
Reply all
Reply to author
Forward
0 new messages