Skip to content

Instantly share code, notes, and snippets.

Created December 16, 2013 02:26
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
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"];
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