Skip to content

Reachability is a dead-simple wrapper for SCNetworkReachability. It provides a very simple interaction with the network status.

License

Notifications You must be signed in to change notification settings

bikemap/reachability

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

Reachability

Reachability is a dead-simple wrapper for SCNetworkReachability. It provides very simple interaction with the network status. And honestly, that is all you need, no-one cares about the interventionRequired state.

You have four options:

  • online
  • cellular
  • offline
  • unkown

And there is a convenience isOnline parameter.

Usage

Sync

You can use Reachability to query the current status.

  let reachability = Reachability()
  print(reachability.status)

  if reachability.isOnline {
    // True, when on wifi or on cellular network.
  }

Async

If you provide a handler, a listener is going to be setup, and the closure is called when there is a change in the network status.

Simple

  Reachability { status, _ in
    print(status)
  }

Based on previous result

  Reachability { status, from in
    if status == .online && from == .cellular {
      // User just joined a wifi.
      // Continue download or something.
    }
  }

About

Reachability is a dead-simple wrapper for SCNetworkReachability. It provides a very simple interaction with the network status.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages