iOS-swift-Almofire-Network Reachability


  static func checkNetWorkReachability(reachable: () -> Void, unRechable: () -> Void) {
    if let isReachable = manager?.isReachable where isReachable == true {
      reachable()
    } else {
      unRechable()
    }
    self.listeningReachability(reachable, unRechable: unRechable)
  }
  
  static func listeningReachability(reachable: () -> Void, unRechable: () -> Void) {
    manager?.listener = { status in
      switch status {
      case .NotReachable:
        NSNotificationCenter.defaultCenter().postNotificationName(AccountService.kNetWorkUnReachability,
                                                                  object: nil)
        unRechable()
      default:
        reachable()
      }
    }
    manager?.startListening()
  }

你可能感兴趣的:(iOS-swift-Almofire-Network Reachability)