Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- func tableView(_ tableView: UITableView, moveRowAt sourceIndexPath: IndexPath, to destinationIndexPath: IndexPath) {
- let appDelegate = UIApplication.shared.delegate as! AppDelegate
- let context = appDelegate.persistentContainer.viewContext
- let movedCampSites = itemName[sourceIndexPath.item]
- itemName.remove(at: sourceIndexPath.item)
- itemName.insert(movedCampSites, at: destinationIndexPath.item)
- context.delete(itemName[sourceIndexPath.row])
- context.insert(itemName[destinationIndexPath.row])
- do
- {
- try context.save()
- }
- catch
- {
- print("Could not move rows")
- }
- }
Add Comment
Please, Sign In to add comment