Created
July 10, 2017 14:30
-
-
Save nyg/45ac81abd94efc38b64fbc4cc964e5fa to your computer and use it in GitHub Desktop.
Adding `shared` property to UIApplicationDelegate
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
// https://stackoverflow.com/a/45014628/5536516 | |
extension UIApplicationDelegate { | |
static var shared: Self { | |
return UIApplication.shared.delegate! as! Self | |
} | |
} | |
/* | |
use like this: | |
let appDelegate = MyAppDelegate.shared // will be of type MyAppDelegate | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment