Reachability.swift: Swift 3 / iOS 10

Created on 15 Jun 2016  路  13Comments  路  Source: ashleymills/Reachability.swift

Please check out the ios10 feature branch (https://github.com/ashleymills/Reachability.swift/tree/feature/ios10) which has been updated to Swift 3

Please log any issues and create PRs to that branch

enhancement help wanted

Most helpful comment

I forked the repo and have two branches going now:

I'm happy to pull them back into the main project eventually. My suggestion would be to ship the 2.3 branch at Reachability 3.0 and Swift 3.0 as Reachability 4.0 so that people can pick and choose which version of Swift they want to use.

All 13 comments

any plans for a Swift 2.3 branch?

I forked the repo and have two branches going now:

I'm happy to pull them back into the main project eventually. My suggestion would be to ship the 2.3 branch at Reachability 3.0 and Swift 3.0 as Reachability 4.0 so that people can pick and choose which version of Swift they want to use.

Hi . I don't know why the NotificationCenter only runs once , it only runs when the app launching,
After than , I disconnect the wifi , nothing happen ?
Some stack overflow's answer said the notifi name is change to "kReachabilityChangedNotification"
But still not works for me .
I'm using branch "feature/ios10" and Xcode beta 3

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
var reachability: Reachability!

        do {
            reachability = try Reachability.reachabilityForInternetConnection()
        } catch {
            print("Unable to create Reachability")
        }

        NotificationCenter.default.addObserver(self, selector: #selector(AppDelegate.reachabilityChanged(note:)), name: ReachabilityChangedNotification,object: reachability)
do {
            try reachability?.startNotifier()
        } catch {
            print("Unable to start notifier")
        }

        return true
    }
func reachabilityChanged(note: NSNotification) {

        let reachability = note.object as! Reachability

        if reachability.isReachable() {
            if reachability.isReachableViaWiFi() {
                print("Reachable via WiFi")
            } else {
                print("Reachable via Cellular")
            }
        } else {
            print("Network not reachable")
        }
    }

@WebberLai Make your var reachability: Reachability! an instance variable on your AppDelegate

@justin I'm not sure about supporting Swift 2.3 - I think I'd rather push it forward to Swift 3.0 and not have to maintain 2 branches.

The idea is to hard lock a release at 2.3 and then you can do whatever with 3.0 going forward. We aren't going to be able to update to Swift 3 for a few months probably, but will move to xcode 8. Not having a 2.3 release we can at least tag our Carthage release to is going to present issues.

@ashleymills Thanks . It works now .

i am getting error

@ansr123 I'm not

i am getting error as Reachability as no member reachabilityForInternetConnection at
reachability = try Reachability.reachabilityForInternetConnection()

i did't install the carthage

Get Updated ReadMe

Previously:

class func reachabilityForInternetConnection() throws

Now:

init?()

@kamalupasena so it when from this:
let netStatus : NetworkStatus = reachability.currentReachabilityStatus()
to
let netStatus : NetworkStatus = reachability.init?()

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Aishly picture Aishly  路  22Comments

AlekseiR picture AlekseiR  路  4Comments

amit3609 picture amit3609  路  17Comments

tjarbo picture tjarbo  路  12Comments

bclymer picture bclymer  路  12Comments