Skip to content

Instantly share code, notes, and snippets.

@vialyx
Created April 24, 2018 08:03
Show Gist options
  • Save vialyx/62ec15f6bdcfb3a648a5227e30586ccd to your computer and use it in GitHub Desktop.
Save vialyx/62ec15f6bdcfb3a648a5227e30586ccd to your computer and use it in GitHub Desktop.
// MARK: - strong reference counting
var customer1stRef: Customer? = nil
var customer2ndRef: Customer? = nil
customer1stRef = Customer(udid: "1st", name: "Maxim")
/*
print: 1st initialized
*/
customer2ndRef = customer1stRef
customer1stRef = nil
/*
Customer class instance don't deallocated after nil set to customer1stRef.
That happened because it has a strong reference in customer2ndRef
*/
customer2ndRef = nil
/*
print: 1st deinitialized
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment