Reachability
Reachability copied to clipboard
Allow subclasses to manipulate reachabilityFlags
Previously, many methods made a direct call to SCNetworkReachabilityGetFlags(reachabilityRef, &flags)
to get the flags. Since we already have a method that does this, we can "program to an interface" and have all flag queries go through -reachabilityFlags
to gain readability (IMO) and more importantly the ability of subclasses overriding -reachabilityFlags
for automated testing purposes.
Note that I did this in the github file editor to see if there's any interest. If you like the general idea, let me know and I'll do more extensive testing.
If you really like the idea, it would be extra-cool to have Reachability have flag manipulation built into reachability instances, or perhaps provide an official category extension to enable it.
Is my use case clear?
Yes that seems reasonable & understandable. Let me look it over and I'll try merging.
The problem with using the flags
like this is, its dependent on the callback method being notified by the system.
I've seen cases where this doesn't happen, and flags
is out of sync with the system, however the call to SCNetworkReachabilityGetFlags
actually returns the correct state.