We all learned in college that global variables are undesirable, but most iOS applications need to access some global members of the shared UIApplication object.
I appreciate that the Swift syntax is getting better and better, but it’s still a moving target and challenges my noodle to keep up.
Here’s a quick cheat sheet on accessing AppDelegate through the versions. In each example, we’re getting our shared appDelegate to check a variable called
let appDelegate = UIApplication.shared.delegate as! AppDelegate let isProd = appDelegate.isProduction
let appDelegate = UIApplication.sharedApplication().delegate as! AppDelegate let isProd = appDelegate.isProduction
let appDelegate = UIApplication.sharedApplication as AppDelegate let isProd = appDelegate.isProduction