Created
January 9, 2014 09:56
-
-
Save kuetsuhara/8331915 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) CBLReplication *pull; | |
@property (nonatomic, strong) CBLReplication *push; | |
//そして、以下のようなメソッドを作ります。 | |
- (void)syncServer{ | |
// sync method | |
AppDelegate *ap = ApplicationDelegate; | |
NSArray *repls = [ap.database replicateWithURL:[NSURL URLWithString:@"https://yourId:password@yourId.cloudant.com/dbName"] | |
exclusively:YES]; | |
self.pull = [repls objectAtIndex: 0]; | |
self.push = [repls objectAtIndex: 1]; | |
// completeではなく、modeを取得する | |
// completeの場合、completeしない場合があるため。 | |
[_pull addObserver:self | |
forKeyPath:@"mode" | |
options:0 | |
context:NULL]; | |
[_push addObserver:self | |
forKeyPath:@"mode" | |
options:0 | |
context:NULL]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment