《省钱达人》与《猎豆优选》UI相同版。域名tbk

Reachability.h 1.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /*
  2. Copyright (C) 2016 Apple Inc. All Rights Reserved.
  3. See LICENSE.txt for this sample’s licensing information
  4. Abstract:
  5. Basic demonstration of how to use the SystemConfiguration Reachablity APIs.
  6. */
  7. #import <Foundation/Foundation.h>
  8. #import <SystemConfiguration/SystemConfiguration.h>
  9. #import <netinet/in.h>
  10. typedef enum : NSInteger {
  11. NotReachable = 0,
  12. ReachableViaWiFi,
  13. // ReachableViaWWAN
  14. ReachableViaWWAN,
  15. kRaeachableVia4G,
  16. kReachableVia2G,
  17. kReachableVia3G
  18. } NetworkStatus;
  19. #pragma mark IPv6 Support
  20. //Reachability fully support IPv6. For full details, see ReadMe.md.
  21. extern NSString *kReachabilityChangedNotification;
  22. @interface Reachability : NSObject
  23. /*!
  24. * Use to check the reachability of a given host name.
  25. */
  26. + (instancetype)reachabilityWithHostName:(NSString *)hostName;
  27. /*!
  28. * Use to check the reachability of a given IP address.
  29. */
  30. + (instancetype)reachabilityWithAddress:(const struct sockaddr *)hostAddress;
  31. /*!
  32. * Checks whether the default route is available. Should be used by applications that do not connect to a particular host.
  33. */
  34. + (instancetype)reachabilityForInternetConnection;
  35. #pragma mark reachabilityForLocalWiFi
  36. //reachabilityForLocalWiFi has been removed from the sample. See ReadMe.md for more information.
  37. //+ (instancetype)reachabilityForLocalWiFi;
  38. /*!
  39. * Start listening for reachability notifications on the current run loop.
  40. */
  41. - (BOOL)startNotifier;
  42. - (void)stopNotifier;
  43. - (NetworkStatus)currentReachabilityStatus;
  44. /*!
  45. * WWAN may be available, but not active until a connection has been established. WiFi may require a connection for VPN on Demand.
  46. */
  47. - (BOOL)connectionRequired;
  48. @end