Skip to content

Commit

Permalink
[models] Remove redundant object fetch and fix build break for picky …
Browse files Browse the repository at this point in the history
…compilers.
  • Loading branch information
jverkoey committed Nov 14, 2012
1 parent a523573 commit 93d7b3b
Showing 1 changed file with 15 additions and 16 deletions.
31 changes: 15 additions & 16 deletions src/models/src/NIMutableTableViewModel.m
Original file line number Diff line number Diff line change
Expand Up @@ -188,27 +188,26 @@ - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEd

///////////////////////////////////////////////////////////////////////////////////////////////////
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath {
if ([self.delegate respondsToSelector:@selector(tableViewModel:canMoveObject:atIndexPath:inTableView:)]) {
id object = [self objectAtIndexPath:indexPath];
return [self.delegate tableViewModel:self canMoveObject:object atIndexPath:indexPath inTableView:tableView];
} else {
return NO;
}
if ([self.delegate respondsToSelector:@selector(tableViewModel:canMoveObject:atIndexPath:inTableView:)]) {
id object = [self objectAtIndexPath:indexPath];
return [self.delegate tableViewModel:self canMoveObject:object atIndexPath:indexPath inTableView:tableView];
} else {
return NO;
}
}


///////////////////////////////////////////////////////////////////////////////////////////////////
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)sourceIndexPath toIndexPath:(NSIndexPath *)destinationIndexPath {
id object = [self objectAtIndexPath:sourceIndexPath];
BOOL shouldMove = YES;
if ([self.delegate respondsToSelector:@selector(tableViewModel:shouldMoveObject:atIndexPath:toIndexPath:inTableView:)]) {
shouldMove = [self.delegate tableViewModel:self shouldMoveObject:object atIndexPath:sourceIndexPath toIndexPath:destinationIndexPath inTableView:tableView];
}
if (shouldMove) {
id object = [self objectAtIndexPath:sourceIndexPath];
[self removeObjectAtIndexPath:sourceIndexPath];
[self insertObject:object atRow:destinationIndexPath.row inSection:destinationIndexPath.section];
}
id object = [self objectAtIndexPath:sourceIndexPath];
BOOL shouldMove = YES;
if ([self.delegate respondsToSelector:@selector(tableViewModel:shouldMoveObject:atIndexPath:toIndexPath:inTableView:)]) {
shouldMove = [self.delegate tableViewModel:self shouldMoveObject:object atIndexPath:sourceIndexPath toIndexPath:destinationIndexPath inTableView:tableView];
}
if (shouldMove) {
[self removeObjectAtIndexPath:sourceIndexPath];
[self insertObject:object atRow:destinationIndexPath.row inSection:destinationIndexPath.section];
}
}

@end
Expand Down

0 comments on commit 93d7b3b

Please sign in to comment.