Last active
September 3, 2016 04:21
-
-
Save mikekavouras/2020f6e40ab590d8d6ff2b472c683592 to your computer and use it in GitHub Desktop.
Memory Leak
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Passing a closure with a reference to `self` which is ultimately stored as | |
// an instance property. Strong reference = retain cycle. | |
collectionView?.addInfiniteScrollWithHandler { collectionView in | |
self.update(false) | |
} | |
// Fixed: Make sure `self` that is being passed is explicitly marked as `weak` | |
// to force a weak reference. | |
collectionView?.addInfiniteScrollWithHandler { [weak self] collectionView in | |
self?.update(false) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment