Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
//まずはプロパティを宣言
@property (nonatomic, strong) CBLLiveQuery *liveQuery;
//ViewDidLoadに以下を追加します。
AppDelegate *ap = ApplicationDelegate;
self.liveQuery = [[ap.database queryAllDocuments] asLiveQuery];
[self.liveQuery addObserver:self forKeyPath:@"rows" options:0 context:NULL];
//そして、以下を追加。
//(レプリケーションを追加していれば、すでにあるものの中にif文を追加する)
- (void) observeValueForKeyPath:(NSString *)keyPath
ofObject:(id)object
change:(NSDictionary *)change
context:(void *)context
{
if (object == self.liveQuery) {
NSLog(@"live query”);
// ライブクエリ時の処理をここに書く
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment