Important: This check should always be performed asynchronously. The majority of answers below are synchronous so be careful otherwise you’ll freeze up your app.

Swift

1) Install via CocoaPods or Carthage: https://github.com/ashleymills/Reachability.swift

let reachability = Reachability()!reachability.whenReachable = { reachability in
if reachability.connection == .wifi {
print("Reachable via WiFi")…