Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow subclasses to manipulate reachabilityFlags #57

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

woahdae
Copy link

@woahdae woahdae commented Jan 1, 2014

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?

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 testing purposes.
@tonymillion
Copy link
Owner

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

@tonymillion
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants