Avatar ·

How to get a reference to AppDelegate in Swift? (iOS)

Hi everyone! I'm a beginner iOS developer in Swift and I've run into a problem. I need to access the AppDelegate object from another class (for example, from a ViewController or a regular data manager) to call some method or access a property. Previously, when I wrote in Objective-C, I used `[[UIApplication sharedApplication] delegate]`. But in Swift, it doesn't work the same way. I tried writing `UIApplication.sharedApplication().delegate`, but Xcode gives an error or says I need to do a type cast. Here's an example of the code I'm trying to write in my ViewController: ```swift class MyViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() // Trying to get AppDelegate let appDel