Skip to content

Instantly share code, notes, and snippets.

@jk
Created December 5, 2015 10:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jk/f5be951a33d7046cb667 to your computer and use it in GitHub Desktop.
Save jk/f5be951a33d7046cb667 to your computer and use it in GitHub Desktop.
Desired refactoring
class MyViewController : UIViewController {
func refactorThis() {
if let navigationController = navigationController,
let topViewController = navigatonController.topViewController,
let someProperty = topViewController.someproperty {
someProperty = "new value"
}
}
func toThat() {
navigationController?.topViewController?.someProperty = "new value"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment