Guest User

Untitled

a guest
Jul 22nd, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. func tableView(_ tableView: UITableView, moveRowAt sourceIndexPath: IndexPath, to destinationIndexPath: IndexPath) {
  2.  
  3.  
  4. let appDelegate = UIApplication.shared.delegate as! AppDelegate
  5. let context = appDelegate.persistentContainer.viewContext
  6. let movedCampSites = itemName[sourceIndexPath.item]
  7. itemName.remove(at: sourceIndexPath.item)
  8. itemName.insert(movedCampSites, at: destinationIndexPath.item)
  9. context.delete(itemName[sourceIndexPath.row])
  10. context.insert(itemName[destinationIndexPath.row])
  11.  
  12. do
  13. {
  14. try context.save()
  15. }
  16. catch
  17. {
  18. print("Could not move rows")
  19. }
  20.  
  21.  
  22.  
  23. }
Add Comment
Please, Sign In to add comment