Hi ,
I noticed the last update change .none
to .unavailable
that mean .none
should be removed
but Xcode ask me to add both on switch !
I did do clean build but noting change untill I add both !
also
let reachability = Reachability()!
is force me to remove ! and see it not optional
Cannot force unwrap value of non-optional type 'Reachability'
and after I change it to
let reachability = Reachability()
Call can throw, but errors cannot be thrown out of a property initializer
the previous version was working fine !
let reachability = try? Reachability()
it's working for me properly.
.none
is only deprecated, not removed. It will be removed in a future version. In your switch statement, you can use both in the same case like: case .unavailable, .none:
let reachability = try! Reachability()
with the new version as an equivalent to let reachability = Reachability()!
@djtech42 Thanks for following up on this
Cheers
Ash
Also you have to use
NotificationCenter.default.addObserver(self, selector: #selector(self.reachabilityChanged),name: Notification.Name.reachabilityChanged,object: reachable)
do{
try reachable!.startNotifier()
}catch{
print("could not start reachability notifier")
}
in AppDelegate didFinishLaunchingWithOptions
.
Though .none
is deprecated, not removed, the way we deprecated it is not appropriate.
A more suitable way is to define a static constant none
and make it equal to the new case . unavailable
.
And then you don't need to list .none
in a switch statement anymore.
You can see the changes in PR https://github.com/ashleymills/Reachability.swift/pull/371:
Most helpful comment
.none
is only deprecated, not removed. It will be removed in a future version. In your switch statement, you can use both in the same case like:case .unavailable, .none:
let reachability = try! Reachability()
with the new version as an equivalent tolet reachability = Reachability()!