Created
May 20, 2017 11:20
-
-
Save dhiraj-das/14ed8bd0078ad5bfe1fea8b4c6273e5a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// ViewController.swift | |
// EmptyStateDemo | |
// | |
// Created by Dhiraj Das on 5/20/17. | |
// Copyright © 2017 Dhiraj Das. All rights reserved. | |
// | |
import UIKit | |
import ReachabilitySwift | |
class ViewController: UIViewController { | |
@IBOutlet weak var noInternetImageView: UIImageView! | |
let rechability = Reachability() | |
var isRechable: Bool { | |
if let _rechability = rechability { | |
return _rechability.isReachable | |
} | |
return false | |
} | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
try? rechability?.startNotifier() | |
NotificationCenter.default.addObserver(self, selector: #selector(networkChanged), name: ReachabilityChangedNotification, object: nil) | |
} | |
func networkChanged() { | |
noInternetImageView.isHidden = isRechable | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment