跟踪网络可达性变化Swift库:SSASwiftReachability
jopen
9年前
SSASwiftReachability 是跟踪网络可达性变化的Swift库。
使用:
override func viewDidLoad() { super.viewDidLoad() // MARK: Start Monitoring For Network Reachability Changes. SSASwiftReachability.sharedManager?.startMonitoring() // MARK: Listen For Network Reachability Changes NSNotificationCenter.defaultCenter().addObserver(self, selector: "reachabilityStatusChanged:", name: reachabilityDidChangeNotification, object: nil) } func reachabilityStatusChanged(notification: NSNotification) { if let info = notification.userInfo { if let s = info[reachabilityNotificationStatusItem] { print(s.description) } } }