From fe6f5a7d6f7b7f9187460df4e30660dc34b93ef2 Mon Sep 17 00:00:00 2001 From: Christoffer Winterkvist Date: Mon, 25 Nov 2019 15:00:31 +0100 Subject: [PATCH] Use performBatchUpdates completion in extensions --- Differific.podspec | 2 +- Source/iOS+tvOS/UICollectionView+Extensions.swift | 4 ++-- Source/iOS+tvOS/UITableView+Extensions.swift | 5 +++-- Source/macOS/NSCollectionView+Extensions.swift | 6 +++--- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/Differific.podspec b/Differific.podspec index d2a3a66..92c31fe 100644 --- a/Differific.podspec +++ b/Differific.podspec @@ -1,7 +1,7 @@ Pod::Spec.new do |s| s.name = "Differific" s.summary = "A fast and convenient diffing framework" - s.version = "0.8.3" + s.version = "0.8.4" s.homepage = "https://github.com/zenangst/Differific" s.license = 'MIT' s.author = { "Christoffer Winterkvist" => "christoffer@winterkvist.com" } diff --git a/Source/iOS+tvOS/UICollectionView+Extensions.swift b/Source/iOS+tvOS/UICollectionView+Extensions.swift index 0bcb1ec..05c811a 100644 --- a/Source/iOS+tvOS/UICollectionView+Extensions.swift +++ b/Source/iOS+tvOS/UICollectionView+Extensions.swift @@ -41,9 +41,9 @@ extension UICollectionView { moveItem(at: $0.from, to: $0.to) } } + }, completion: { _ in + completion?() }) - - completion?() } private func validateUpdates(_ collection: [IndexPath], then: ([IndexPath]) -> Void) { diff --git a/Source/iOS+tvOS/UITableView+Extensions.swift b/Source/iOS+tvOS/UITableView+Extensions.swift index 2c4afea..3b10f53 100644 --- a/Source/iOS+tvOS/UITableView+Extensions.swift +++ b/Source/iOS+tvOS/UITableView+Extensions.swift @@ -42,6 +42,8 @@ public extension UITableView { if !result.moves.isEmpty { result.moves.forEach { moveRow(at: $0.from, to: $0.to) } } + }, completion: { _ in + completion?() }) } else { beginUpdates() @@ -53,9 +55,8 @@ public extension UITableView { result.moves.forEach { moveRow(at: $0.from, to: $0.to) } } endUpdates() + completion?() } - - completion?() } private func validateUpdates(_ collection: [IndexPath], diff --git a/Source/macOS/NSCollectionView+Extensions.swift b/Source/macOS/NSCollectionView+Extensions.swift index 8e2306f..741f939 100644 --- a/Source/macOS/NSCollectionView+Extensions.swift +++ b/Source/macOS/NSCollectionView+Extensions.swift @@ -38,11 +38,11 @@ public extension NSCollectionView { if !result.moves.isEmpty { result.moves.forEach { object.moveItem(at: $0.from, to: $0.to) } } - }, completionHandler: nil) + }, completionHandler: { _ in + completion?() + }) needsLayout = true - - completion?() } private func validateUpdates(_ collection: [IndexPath], then: (Set) -> Void) {