Gold Challenge


#1

Assuming the additions made for the silver challenge:

In ItemsViewController.m add the following method -

- (NSIndexPath *)tableView:(UITableView *)tableView 
              targetIndexPathForMoveFromRowAtIndexPath:(NSIndexPath *)sourceIndexPath
                                   toProposedIndexPath:(NSIndexPath *)proposedDestinationIndexPath
{
    NSLog(@"%@", proposedDestinationIndexPath);
    if (proposedDestinationIndexPath.row == [tableView numberOfRowsInSection:0] - 1)
    {
        return [NSIndexPath indexPathForRow:proposedDestinationIndexPath.row - 1 inSection:0];
    }

    return proposedDestinationIndexPath;
}

This should cause an attempt to drag a row below the bottom row to bounce back to the second to last row instead.

Note: This is using a single-sectioned table view so if you used sections you obviously need additional code to input the correct section arguments.