Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Couchbase LiteをCBLDocumentベースで更新
- (void)updateDocument:(NSIndexPath *)indexPath{
// check情報を取得
NSMutableDictionary *dataDic = [NSMutableDictionary dictionaryWithDictionary:dataArray[indexPath.row]];
// 現在のチェックを受け取る
BOOL wasChecked = [[dataDic valueForKey:@"check"] boolValue];
// 結果を反転させてセットする
[dataDic setObject: [NSNumber numberWithBool: !wasChecked] forKey:@"check"];
// Updateを準備する
NSError *err;
AppDelegate *ap = ApplicationDelegate;
CBLDocument *doc = [ap.database documentWithID:[dataDic objectForKey:@"_id"]];
// Update実行
if (![doc putProperties:dataDic error: &err]){
[self showErrorAlert: @"Couldn't update the item"];
}
else{
NSLog(@"Update Complete!");
[self loadAllDocuments];
[self.tableView reloadData];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.