Skip to content

Instantly share code, notes, and snippets.

@hamsternik
Created December 28, 2020 01:56
Show Gist options
  • Save hamsternik/623cab2b318c4813416f8a42f5a0c51f to your computer and use it in GitHub Desktop.
Save hamsternik/623cab2b318c4813416f8a42f5a0c51f to your computer and use it in GitHub Desktop.
mistake #1 - forget to use `weak` memory modifier for the delegate variable
protocol UserDetailsViewControllerDelegate: class {
func update(with user: User)
}
final class UserDetailsViewController: UIViewController {
var delegate: UserDetailsViewControllerDelegate?
// some code below ...
@IBAction func didTapContinueButton(_ sender: UIButton) {
let user = // get new instance of the User or use the existing one
delegate?.update(with: user)
}
}
@hamsternik
Copy link
Author

hard-skills-mistake-1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment