Open Source Swift Library Providing A Clean Syntax For Easy Reachability Tracking

About a year ago I mentioned an objective-c library providing a nice blocks based syntax for tracking reachability called JTSReachability.

Here’s an open source Swift library called SSASwiftReachability from Sebastian that provides a nice clean syntax for monitoring reachability changes in Swift.

This code snippet from the readme shows how to use SSASwiftReachability:

override func viewDidLoad() {
        super.viewDidLoad()

<pre><code>     // MARK: Start Monitoring For Network Reachability Changes.
    SSASwiftReachability.sharedManager?.startMonitoring()

    // MARK: Listen For Network Reachability Changes
    NSNotificationCenter.defaultCenter().addObserver(self, selector: "reachabilityStatusChanged:", name: reachabilityDidChangeNotification, object: nil)
}

func reachabilityStatusChanged(notification: NSNotification) {
    if let info = notification.userInfo {

        if let s = info[reachabilityNotificationStatusItem] {
            print(s.description)
        }
    }
}
</code></pre>

You can find SSASwiftReachability on Github here.

A nice library for monitoring reachability changes in Swift.

Original article: Open Source Swift Library Providing A Clean Syntax For Easy Reachability Tracking

©2015 iOS App Dev Libraries, Controls, Tutorials, Examples and Tools. All Rights Reserved.

Leave a Reply

Your email address will not be published. Required fields are marked *