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