Guest User

Untitled

a guest
Jul 22nd, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. func internetConnect() {
  2. NotificationCenter.default.addObserver(self, selector: #selector(internetChanged), name: Notification.Name.reachabilityChanged, object: reachability)
  3. do{
  4. try reachability.startNotifier()
  5. }catch{
  6. print("could not start reachability notifier")
  7. }
  8. }
  9.  
  10. @objc func internetChanged(note: Notification) {
  11. let reachability = note.object as! Reachability
  12. if reachability.connection != .none{
  13. DispatchQueue.main.async {
  14. self.internetLabel.isHidden = true
  15. }
  16. }else{
  17. DispatchQueue.main.async {
  18. self.internetLabel.isHidden = false
  19. }
  20. }
  21. }
  22.  
  23. func internetConnect(label:UILabel) {
  24. NotificationCenter.default.addObserver(self, selector: #selector(internetChanged), name: Notification.Name.reachabilityChanged, object: reachability)
  25. do{
  26. try reachability.startNotifier()
  27. }catch{
  28. print("could not start reachability notifier")
  29. }
  30. }
  31.  
  32. selector: #selector(internetChanged)
Add Comment
Please, Sign In to add comment