URL: Reachability
★ 通信チェック
import UIKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
let reachability = Reachability.reachabilityForInternetConnection()
switch reachability.currentReachabilityStatus() {
case NotReachable :
print("通信できない")
default:
print("通信できる")
}
}
// Same Method
func checkHasNetworkConnection() -> Bool {
let reachability = Reachability.reachabilityForInternetConnection()
let networkStatus: Int = reachability.currentReachabilityStatus().rawValue
return networkStatus != 0
}
}