1

I'm trying to integrate app level notifications for ReachabilitySwift https://github.com/ashleymills/Reachability.swift/tree/master

So when I set the selector to #selector(reachabilityChanged(_:)) is says that there is a "Use of unresolved identifier" but I have the function right in the AppDelegate class.....so I'm a bit confused.

class AppDelegate: UIResponder, UIApplicationDelegate {

    var window: UIWindow?
    struct Constants {
        public static let googleApi = "xxx"
    }
    let centralreachability = Reachability()


    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {

        NotificationCenter.default.addObserver(self, selector: #selector(reachabilityChanged(_:)), name: .reachabilityChanged, object: centralreachability)

        do{
            try centralreachability?.startNotifier()
        }
            catch{
                print("could not start reachability notifier")
            }



        NetworkActivityIndicatorManager.shared.isEnabled = true

        return true
    }

    func reachabilityChanged(note: Notification) {

        let reachability = note.object as! Reachability

        switch reachability.connection {
        case .wifi:
            print("Reachable via WiFi")
        case .cellular:
            print("Reachable via Cellular")
        case .none:
            print("Network not reachable")
        }
    }
    .....rest of AppDelegate
Ashley Mills
  • 50,474
  • 16
  • 129
  • 160
BostonMacOSX
  • 1,369
  • 2
  • 17
  • 38

0 Answers0