Created
December 27, 2013 07:29
-
-
Save kuetsuhara/8143715 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//まずはプロパティを宣言 | |
@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