Reachability.swift
Reachability.swift copied to clipboard
Initial reachability notification is not sent on main thread
trafficstars
This code:
// Perform an intial check
reachabilitySerialQueue.async {
self.reachabilityChanged()
}
defined here: https://github.com/ashleymills/Reachability.swift/blob/master/Reachability/Reachability.swift#L162 is triggered on reachability's own queue and posts NSNotification on the same queue, while documentation states:
They will be delivered on the MAIN THREAD, so you can do UI updates from within the function.
Which is not correct.
Perhaps you are not looking at the current release? Since the 4.0.0 release reachabilityChanged() asyncs back to the main queue:
DispatchQueue.main.async {
block?(self)
self.notificationCenter.post(name: .reachabilityChanged, object:self)
}