Skip to content

Instantly share code, notes, and snippets.

@dhiraj-das
Created May 20, 2017 11:20
Show Gist options
  • Save dhiraj-das/14ed8bd0078ad5bfe1fea8b4c6273e5a to your computer and use it in GitHub Desktop.
Save dhiraj-das/14ed8bd0078ad5bfe1fea8b4c6273e5a to your computer and use it in GitHub Desktop.
//
// 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