Last active
March 18, 2020 18:10
-
-
Save longvudai/acb9520e65013c054968f793b5825060 to your computer and use it in GitHub Desktop.
ARC-medium
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Person { | |
| let name: String | |
| init(name: String) { | |
| self.name = name | |
| print("\(name) is being initialized") | |
| } | |
| deinit { | |
| print("\(name) is being deinitialized") | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var reference1 = Person(name: "John Appleseed") | |
| // output: "John Appleseed is being initialized" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var reference2: Person? | |
| var reference3: Person? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| reference2 = reference1 | |
| reference3 = reference1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| reference1 = nil // reference counts = 2 | |
| reference2 = nil // reference counts = 1 | |
| reference3 = nil // reference counts = 0 | |
| // output: "John Appleseed is being deinitialized" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment