Skip to content

Instantly share code, notes, and snippets.

@kuetsuhara
Created January 9, 2014 09:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kuetsuhara/8331915 to your computer and use it in GitHub Desktop.
Save kuetsuhara/8331915 to your computer and use it in GitHub Desktop.
//まずは、以下のプロパティを宣言します。
@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