Check internet connection with Swift 4.x

i0S Swift Issue
Internet connection testing is a necessary thing when programming applications for devices running iOS.

The code below swift reference from source: stackoverflow

Create Reachability.swift file:

Usage: Initialize it in your AppDelegate.swift didFinishLaunchingWithOptions method and handle any errors that might occur:

View controller sample: