I Created Reachability in one Demo project in that project i have two view controllers if internet connection is there i am displaying OnlineViewController if internet connection is not there I am displaying OfflineViewController. See the following Code which i have implemented in Appdelegate.swift.
var reachability:Reachability?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
NotificationCenter.default.addObserver(self, selector: #selector(reachabilityStatusChanged(_:)), name: .reachabilityChanged, object: nil)
reachability = Reachability.forInternetConnection()
reachability!.startNotifier()
return true
}
And My function is like This
@objc func reachabilityStatusChanged(_ sender: NSNotification) {
var remoteHostStatus = self.reachability!.currentReachabilityStatus()
if (remoteHostStatus == NotReachable)
{
print ("no net")
let testController = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "OfflineViewController") as! OfflineViewController
window!.rootViewController = testController
window!.makeKeyAndVisible()
}
else
{
let testController = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "OnlineViewController") as! OnlineViewController
window!.rootViewController = testController
window!.makeKeyAndVisible()
print (" wifi")
}
}
Now my question is i want to implement same thing in my realtime project in that project i have 3 storyboards and mutiple viewcontrollers. so how to display user current screen again if internet connection is there.