Skip to content

Instantly share code, notes, and snippets.

@uc-compass-bot
Created October 15, 2019 14:27
Show Gist options
  • Save uc-compass-bot/ee6bc7a43a7f7e4a31513aaca375e664 to your computer and use it in GitHub Desktop.
Save uc-compass-bot/ee6bc7a43a7f7e4a31513aaca375e664 to your computer and use it in GitHub Desktop.
Example Of Retain Cycle On Closure #4 - Fix #2
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