Reachability.swift icon indicating copy to clipboard operation
Reachability.swift copied to clipboard

Initial reachability notification is not sent on main thread

Open akolov opened this issue 9 years ago • 1 comments
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.

akolov avatar Oct 27 '16 11:10 akolov

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)
        }

eliburke avatar Nov 15 '17 16:11 eliburke