From 2d1387e1bff2ed3e965f72dcd6969117fa574249 Mon Sep 17 00:00:00 2001 From: mag Date: Fri, 24 Nov 2017 13:38:46 -0400 Subject: [PATCH] [BUG FIX] Simultaneous access to memory due to KVO This commit fix issue #34, an issue that was previously fixed by PR #73 but reappeared because of Swift-4's improved runtime checks, pointed out by Michael Brown in his blog. http://michael-brown.net/2017/swift-and-kvo-context-variables/ This buf was already fixed by PR 72, however --- Source/PullToRefreshView.swift | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Source/PullToRefreshView.swift b/Source/PullToRefreshView.swift index b825ec3..c850c94 100755 --- a/Source/PullToRefreshView.swift +++ b/Source/PullToRefreshView.swift @@ -7,6 +7,15 @@ // import UIKit +/* + Fix: Simultaneous access to memory due to KVO + + For more information regarding this global variable follow the followinf links: + 1. https://developer.apple.com/swift/blog/?id=6 + 2. http://michael-brown.net/2017/swift-and-kvo-context-variables/ + */ +private var kvoContext = "PullToRefreshKVOContext" + open class PullToRefreshView: UIView { enum PullToRefreshState { case pulling @@ -19,7 +28,6 @@ open class PullToRefreshView: UIView { // MARK: Variables let contentOffsetKeyPath = "contentOffset" let contentSizeKeyPath = "contentSize" - var kvoContext = "PullToRefreshKVOContext" fileprivate var options: PullToRefreshOption fileprivate var backgroundView: UIView