Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/tonisuter/cheddar-ios
Browse files Browse the repository at this point in the history
  • Loading branch information
soffes committed Jan 13, 2013
2 parents 0f0432e + 6408f16 commit a5352fb
Showing 1 changed file with 19 additions and 19 deletions.
38 changes: 19 additions & 19 deletions Classes/CDITasksViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -417,25 +417,25 @@ - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEd


- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)sourceIndexPath toIndexPath:(NSIndexPath *)destinationIndexPath {
if (sourceIndexPath.row == destinationIndexPath.row) {
return;
}
self.ignoreChange = YES;
NSMutableArray *tasks = [self.fetchedResultsController.fetchedObjects mutableCopy];
CDKTask *task = [self objectForViewIndexPath:sourceIndexPath];
[tasks removeObject:task];
[tasks insertObject:task atIndex:destinationIndexPath.row];
NSInteger i = 0;
for (task in tasks) {
task.position = [NSNumber numberWithInteger:i++];
}
[self.managedObjectContext save:nil];
self.ignoreChange = NO;
[CDKTask sortWithObjects:tasks];
if (sourceIndexPath.row != destinationIndexPath.row) {
self.ignoreChange = YES;
NSMutableArray *tasks = [self.fetchedResultsController.fetchedObjects mutableCopy];
CDKTask *task = [self objectForViewIndexPath:sourceIndexPath];
[tasks removeObject:task];
[tasks insertObject:task atIndex:destinationIndexPath.row];
NSInteger i = 0;
for (task in tasks) {
task.position = [NSNumber numberWithInteger:i++];
}
[self.managedObjectContext save:nil];
self.ignoreChange = NO;
[CDKTask sortWithObjects:tasks];
}

[self.tableView reloadData];
}


Expand Down

0 comments on commit a5352fb

Please sign in to comment.