diffabledatasource

Swift DiffableDataSource make insert&delete instead of reload

半城伤御伤魂 提交于 2020-07-05 09:07:48
问题 I have a hard time to understand how DiffableDataSource works. I have ViewModel like this struct ViewModel: Hashable { var id: Int var value: String func hash(into hasher: inout Hasher) { hasher.combine(id) } } I have tableView populated by cachedItems like ViewModele above. When API response arrives I want to add a new one, delete missing one, refresh viewModel.value of items already present in tableView and finally order it. Everything works fine except one thing - reloading items. My

Swift DiffableDataSource make insert&delete instead of reload

夙愿已清 提交于 2020-07-05 09:07:41
问题 I have a hard time to understand how DiffableDataSource works. I have ViewModel like this struct ViewModel: Hashable { var id: Int var value: String func hash(into hasher: inout Hasher) { hasher.combine(id) } } I have tableView populated by cachedItems like ViewModele above. When API response arrives I want to add a new one, delete missing one, refresh viewModel.value of items already present in tableView and finally order it. Everything works fine except one thing - reloading items. My

Swift DiffableDataSource make insert&delete instead of reload

生来就可爱ヽ(ⅴ<●) 提交于 2020-07-05 09:07:17
问题 I have a hard time to understand how DiffableDataSource works. I have ViewModel like this struct ViewModel: Hashable { var id: Int var value: String func hash(into hasher: inout Hasher) { hasher.combine(id) } } I have tableView populated by cachedItems like ViewModele above. When API response arrives I want to add a new one, delete missing one, refresh viewModel.value of items already present in tableView and finally order it. Everything works fine except one thing - reloading items. My

Unable to swipe to delete with tableview using diffable data source in iOS 13

旧时模样 提交于 2020-07-02 11:49:08
问题 I'm updating a UITableViewController to use the new UITableViewDiffableDataSource , I have everything working except Swipe to delete. This is an example of how I use swipe to delete func tableView(_ tableView: UITableView, trailingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? { let lockedAction = UIContextualAction(style: .normal, title: "TEST") { (_, _, completion) in print("tapped....") completion(true) } return UISwipeActionsConfiguration(actions: