How to get sharedApplication in Swift on iOS? [duplicate]

EDIT Swift 4.x

let app = UIApplication.shared.delegate as! AppDelegate

If you’re e.g. not in a ViewController, you must:

import UIKit

Perhaps try:

let app = UIApplication.sharedApplication()

EDIT (Swift 3):

It should be noted that in Swift 3, to accomplish this, you will want to access the shared property instead:

let app = UIApplication.shared

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)