Created
October 15, 2019 14:27
-
-
Save uc-compass-bot/ee6bc7a43a7f7e4a31513aaca375e664 to your computer and use it in GitHub Desktop.
Example Of Retain Cycle On Closure #4 - Fix #2
This file contains 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
class ViewController: UIViewController { | |
private var onTap: (() -> Void)? | |
override func viewDidLoad() { | |
onTap = refreshTitle | |
} | |
private func refreshTitle() { | |
() = { [weak self] in | |
self?.title = "Refreshed" // ✅ Doesn't capture self strongly | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment