Skip to content

Instantly share code, notes, and snippets.

@shabib87
Last active March 13, 2017 10:17
Show Gist options
  • Save shabib87/30f20430345da916f6116578ab7a9a6b to your computer and use it in GitHub Desktop.
Save shabib87/30f20430345da916f6116578ab7a9a6b to your computer and use it in GitHub Desktop.
In support to blog post
class Person {
...
}
class Apartment {
...
weak var person: Person?
...
}
var person: Person? = Person(name: "John Doe")
var apartment: Apartment? = Apartment(number: 123)
person?.apartment = apartment
apartment?.person = person
person = nil
apartment = nil
// output:
// John Doe is being deinitialized
// Apartment 123 is being deinitialized
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment