00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #import <Foundation/Foundation.h>
00029 #import <SystemConfiguration/SystemConfiguration.h>
00030
00031
00037 #ifndef NS_ENUM
00038 #define NS_ENUM(_type, _name) enum _name : _type _name; enum _name : _type
00039 #endif
00040
00041 extern NSString *const kReachabilityChangedNotification;
00042
00043 typedef NS_ENUM(NSInteger, NetworkStatus) {
00044
00045 NotReachable = 0,
00046 ReachableViaWiFi = 2,
00047 ReachableViaWWAN = 1
00048 };
00049
00050 @class Reachability;
00051
00052 typedef void (^NetworkReachable)(Reachability * reachability);
00053 typedef void (^NetworkUnreachable)(Reachability * reachability);
00054
00055
00056 @interface Reachability : NSObject
00057
00058 @property (nonatomic, copy) NetworkReachable reachableBlock;
00059 @property (nonatomic, copy) NetworkUnreachable unreachableBlock;
00060
00061 @property (nonatomic, assign) BOOL reachableOnWWAN;
00062
00063
00064 +(Reachability*)reachabilityWithHostname:(NSString*)hostname;
00065
00066
00067 +(Reachability*)reachabilityWithHostName:(NSString*)hostname;
00068 +(Reachability*)reachabilityForInternetConnection;
00069 +(Reachability*)reachabilityWithAddress:(void *)hostAddress;
00070 +(Reachability*)reachabilityForLocalWiFi;
00071
00072 -(Reachability *)initWithReachabilityRef:(SCNetworkReachabilityRef)ref;
00073
00074 -(BOOL)startNotifier;
00075 -(void)stopNotifier;
00076
00077 -(BOOL)isReachable;
00078 -(BOOL)isReachableViaWWAN;
00079 -(BOOL)isReachableViaWiFi;
00080
00081
00082
00083 -(BOOL)isConnectionRequired;
00084 -(BOOL)connectionRequired;
00085
00086 -(BOOL)isConnectionOnDemand;
00087
00088 -(BOOL)isInterventionRequired;
00089
00090 -(NetworkStatus)currentReachabilityStatus;
00091 -(SCNetworkReachabilityFlags)reachabilityFlags;
00092 -(NSString*)currentReachabilityString;
00093 -(NSString*)currentReachabilityFlags;
00094
00095 @end