Reachability icon indicating copy to clipboard operation
Reachability copied to clipboard

Allow subclasses to manipulate reachabilityFlags

Open woahdae opened this issue 11 years ago • 2 comments

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?

woahdae avatar Jan 01 '14 02:01 woahdae

Yes that seems reasonable & understandable. Let me look it over and I'll try merging.

tonymillion avatar Jan 01 '14 09:01 tonymillion

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.

tonymillion avatar Mar 13 '14 23:03 tonymillion