Check for Change of Internet Connection (Reachability in Swift 3)

Vasil Blanco-Nunev · 15K views · 2017 · 10:52

Open on YouTube

Software (other)Web developmenttutorialdated

Why Stack Overflow recommends it

Stack Overflow users link it in answers about detecting network changes on iOS as a clear walkthrough for setting up the Reachability.swift class.

Recommended by 2 people across 2 different months, 2017 to 2018.

What it is

A 10-minute iOS tutorial by Vasil Blanco-Nunev showing how to monitor internet connectivity in a Swift 3 app using the open-source Reachability.swift library. It walks through adding the class and reacting to connect and disconnect notifications.

What people said

Recommends Junaid Ali · 2017-10 · Stack Overflow · on “Check internet connection (iOS 10)”

This code would be helpful for you. it worked for me in Swift 4 and Xcode 9 Go to [LINK] and copy Reachability.swift file to your project Vasil Nunev clearly explain this Reachability [this video] class ViewController: UIViewController { let reachability = Reachability(); override func viewDidLoad() { super.viewDidLoad() reachability?.whenReachable = { _ in DispatchQueue.main.async { self.view.backgroundColor = UIColor.green } } reachability?.whenUnreachable = { _ in DispatchQueue.main.async { self.view.backgroundColor = UIColor.red } } NotificationCenter.default.addObserver(self, selector: #selector(internetChanged), name: Notification.Name.reachabilityChanged , object: reachability) do{ try rea

Recommends user3826696 · 2018-08 · Stack Overflow · on “How to get notifications for Network change(Connect,Disconnect,Change)”

I followed this tutorial [this video] credit --> Vasil Nunev Download this class and import to my project --> Reachability.swift [LINK] (Reachability.swift) --> Unzip -->Sources/Reachability.swift This is my view controller import UIKit class ViewController: UIViewController { let reachability = Reachability()! override func viewDidLoad() { super.viewDidLoad() reachability.whenReachable = { _ in DispatchQueue.main.async { self.view.backgroundColor = UIColor.green } } reachability.whenUnreachable = { _ in DispatchQueue.main.async { self.view.backgroundColor = UIColor.red } } NotificationCenter.default.addObserver(self, selector: #selector(internetChanged), name: Notification.Name.reachabilityChang

Cites Zash__ · 2018-02 · Stack Overflow · on “Reachability issue while refreshing”

First my code func checkInternetConnection() { reachability.whenReachable = { _ in self.loadPost() self.checkNewMessages() self.slowView.frame.size.height = 0 self.slowView.isHidden = true self.internetStatus.text = "" self.slowView.layer.zPosition = 0 } reachability.whenUnreachable = { _ in self.refreshControl.endRefreshing() self.slowView.backgroundColor = #colorLiteral(red: 1, green: 0.1491314173, blue: 0, alpha: 1) self.slowView.layer.zPosition = 1 self.slowView.frame.size.height = 40 self.slowView.isHidden = false self.internetStatus.text = "Keine Internetverbindung!" self.activityIndicatorView.stopAnimating() self.Indicator.stopAnimating() } NotificationCenter.default.addObserver(self,