From 1eb60a8b62c857d27732900fc4a3e8ad70e4870b Mon Sep 17 00:00:00 2001 From: Lucas Farah Date: Thu, 18 Feb 2016 10:20:16 -0800 Subject: [PATCH] Added methods to README --- README.md | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/README.md b/README.md index 8f54999..9e509df 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,35 @@ A simple class to check for internet connection availability in Swift. Works for ##### Manually - +## Checking internet connection +``` swift +let status = Reach().connectionStatus() + switch status { + case .Unknown, .Offline: + print("Not connected") + case .Online(.WWAN): + print("Connected via WWAN") + case .Online(.WiFi): + print("Connected via WiFi") + } +``` + +## Delegate Method +``` swift + override func viewDidLoad() { + super.viewDidLoad() + + NSNotificationCenter.defaultCenter().addObserver(self, selector: Selector("networkStatusChanged:"), name: ReachabilityStatusChangedNotification, object: nil) + Reach().monitorReachabilityChanges() + } + + func networkStatusChanged(notification: NSNotification) { + let userInfo = notification.userInfo + print(userInfo) + } +``` + + ## Credits