Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 191 Vote(s) - 3.72 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to get sharedApplication in Swift on iOS?

#1
How can I get instance of current UIApplication from View Controller in Swift?

I am getting `Use of unresolved identifier 'sharedApplication'` error with this code:

let app = sharedApplication as UIApplication

Reply

#2
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
Reply

#3
You can do it by

let app = UIApplication.sharedApplication()
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through