0

I want to know if there is a method that goes to another viewcontroller if there is no internet. Please help

Cheers,

Palash

Palash Sharma
  • 662
  • 1
  • 10
  • 18
  • My app requires internet and if internet is not available it will not work so I want it to redirect to a view controller or xib – Palash Sharma Feb 26 '15 at 07:53

1 Answers1

1

You can use Reachability class for this purpose https://github.com/ashleymills/Reachability.swift

Usage:

    let reachability = Reachability.reachabilityForInternetConnection()

reachability.whenReachable = { reachability in
    if reachability.isReachableViaWiFi() {
        println("Reachable via WiFi")
    } else {
        println("Reachable via Cellular")
    }
     //Load your viewController
}
reachability.whenUnreachable = { reachability in
    println("Not reachable")
   //Load your viewController
}

reachability.startNotifier()
Agent Chocks.
  • 1,312
  • 8
  • 19