Last active
March 10, 2018 17:07
-
-
Save jandamm/3421199e0f70d0806cd5a3d02ab6cb6d to your computer and use it in GitHub Desktop.
This file contains 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
import UIKit | |
func returnsNil() -> UIView? { | |
weak var view: UIView? = UIView() | |
return view | |
} | |
func returnsView1() -> UIView? { | |
weak var view: UIView? | |
view = UIView() | |
return view | |
} | |
func returnsView2() -> UIView? { | |
weak var view: UIView? | |
var v: UIView? = UIView() | |
view = v | |
v = nil | |
return view | |
} | |
var v1: UIView? = UIView() | |
func returnsView3() -> UIView? { | |
weak var view: UIView? = v1 | |
v1 = nil | |
return view | |
} | |
var v2: UIView? = UIView() | |
func returnsView4() -> UIView? { | |
weak var view: UIView? | |
view = v2 | |
v2 = nil | |
return view | |
} | |
returnsNil() // nil | |
returnsView1() // UIView | |
returnsView2() // UIView | |
returnsView3() // UIView | |
returnsView4() // UIView | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment