Skip to content

Instantly share code, notes, and snippets.

@uc-compass-bot
Created October 15, 2019 14:20
Show Gist options
  • Save uc-compass-bot/c058c802eab03f77b9511007422f5dfc to your computer and use it in GitHub Desktop.
Save uc-compass-bot/c058c802eab03f77b9511007422f5dfc to your computer and use it in GitHub Desktop.
Example Of Retain Cycle On Delegate
class ParentViewController: UIViewController, ChildViewControllerProtocol {
let childViewController = ChildViewController()
func prepareChildViewController() {
childViewController.delegate = self // ❌ Strong reference, retain cycle
}
}
protocol ChildViewControllerProtocol: class {}
class ChildViewController: UIViewController {
var delegate: ChildViewControllerProtocol?
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment