One Paragraph of project description goes here
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.
override func tableView(_ tableView: UITableView, trailingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? { | |
guard let product = dataStore?.products[indexPath.row] else { | |
return nil | |
} | |
let addAction = UIContextualAction(style: .normal, title: "Add") { [weak self](action, view, completionHandler) in | |
guard let `self` = self else { | |
completionHandler(false) | |
return | |
} |
extension ShoppingListViewController: UITableViewDropDelegate { | |
func tableView(_ tableView: UITableView, performDropWith coordinator: UITableViewDropCoordinator) { | |
guard let destinationIndexPath = coordinator.destinationIndexPath else { | |
return | |
} | |
DispatchQueue.main.async { [weak self] in | |
tableView.beginUpdates() | |
coordinator.items.forEach({ (item) in | |
guard let sourceIndexPath = item.sourceIndexPath, | |
let `self` = self |
extension ShoppingListViewController: UITableViewDragDelegate { | |
func tableView(_ tableView: UITableView, itemsForBeginning session: UIDragSession, at indexPath: IndexPath) -> [UIDragItem] { | |
let listItem = shoppingList[indexPath.row] | |
let provider = NSItemProvider(object: listItem) | |
let dragItem = UIDragItem(itemProvider: provider) | |
return [dragItem] | |
} | |
} |
class Singleton { | |
static let instance = Singleton() | |
} |