From e13871f4a0e88991c11cc81d405c93a4a7ead511 Mon Sep 17 00:00:00 2001 From: Makarov Yury Date: Sat, 27 Jan 2018 16:04:24 +0300 Subject: [PATCH] When inside an implicit transaction completion, use the current item list instead of a captured copy to fix #21 --- MYTableViewIndex/Private/IndexView.swift | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/MYTableViewIndex/Private/IndexView.swift b/MYTableViewIndex/Private/IndexView.swift index 1d51707..b985814 100644 --- a/MYTableViewIndex/Private/IndexView.swift +++ b/MYTableViewIndex/Private/IndexView.swift @@ -48,15 +48,12 @@ class IndexView : UIView { } private func removeItem(_ item: UIView) { - guard let items = items else { - return - } // A little trickery to make item removal look nice when performed inside an animation block // (e.g. when the keyboard shows up) CATransaction.setCompletionBlock { item.alpha = 1 - if (!items.contains(item)) { + if let items = self.items, !items.contains(item) { item.removeFromSuperview() } }