New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Simpler usage? #74
Comments
Hi, You can absolutely do that:
Hope that helps |
in the Example - notifications code section it give the error on the below line reachability.startNotifier() i fixed this error by doing like that But its didn't work for me please somebody help quickly |
would suggest above code example from @ashleymills be added to the Readme |
Good call - I'll get on it. Cheers |
Wouldn't be something like
a bit safer? If the reachability object can't be created this wouldn't crash the app but gracefully report "not connected". |
Thanks to ashleymills very much and sorry for late reply. I do my work like that.
SSASwiftReachability.sharedManager?.startMonitoring()
if SSASwiftReachability.sharedManager?.isReachable() == true {
print("YES CONNECTED")
}
else {
print("NOT CONNECTED")
} B) Observing network notifier
SSASwiftReachability.sharedManager?.startMonitoring()
NSNotificationCenter.defaultCenter().addObserver(self, selector: "reachabilityStatusChanged:", name: SSAReachabilityDidChangeNotification, object: nil)
func reachabilityStatusChanged(notification: NSNotification) {
if let info = notification.userInfo {
if let status = info[SSAReachabilityNotificationStatusItem] {
print(status.description)
let reachability = SSASwiftReachability.sharedManager
switch reachability?.networkReachabilityStatus {
case .ReachableViaWiFi?:
print(NetReachable.REACHABLEVIAWIFI)
break
case .ReachableViaWWAN?:
print(NetReachable.REACHABLEVIAWWAN)
break
case .Reachable?:
print(NetReachable.REACHABLE)
break
case .NotReachable?:
print(NetReachable.NOTREACHABLE)
break
default :
print(NetReachable.NOTREACHABLE)
}
}
}
} |
@imran87,can you provide us with some example.Looks like your code got 2 way. |
@imran87 ,Can you provide some example please.I really want to learn about that and I am beginner at swift. |
Hey Guys, I made it work in my Swift project with the code below in my AppDelegate.swift file for reachabilityswift.
|
The examples in the documentation seem quite code-heavy, and focuses on reachability state changes. In a reachability library I used before (IJReachability, which is no longer updated), I was able to to do this:
... for a one-off check on reachability. Is something similar possible with Reachability.swift ?
The text was updated successfully, but these errors were encountered: