Gold Challenge Solution


#1

For this one I made the decision to have an item that was dragged beyond the last row to settle on the next to last row (i.e. just before the no more items message). Another option would be to have this settle back where it started and to do that you could just return the sourceIndexPath variable. However, I think in the real-world most would want this to settle at the end (but again before the no more items message).

-(NSIndexPath *)tableView:(UITableView *)tableView targetIndexPathForMoveFromRowAtIndexPath:(NSIndexPath *)sourceIndexPath toProposedIndexPath:(NSIndexPath *)proposedDestinationIndexPath
{
   if (proposedDestinationIndexPath.row == [[[BNRItemStore sharedStore]allItems]count])
   {
       int row = proposedDestinationIndexPath.row;
       return [NSIndexPath indexPathForRow:row -1 inSection:proposedDestinationIndexPath.section];
   }
   else return proposedDestinationIndexPath;
}