When developing Web and other network applications, you must confirm the network environment, connection conditions, and other information. If they are not processed, they will not pass Apple's review.
Apple's routine Reachability describes how to obtain/detect the network status.
1. To use Reachability in your program, you only need to copy the Reachability. h and Reachability. m in this routine to your project.
2. Then add SystemConfiguration. framework to the project.
My Version is: Version: 2.2
I added a global -- ReachabilityAutoChecker for Apple's routine.
. H
*
. M file
+ ( ReachabilityAutoChecker *staticChecker = (!===- ()reachabilityChanged:(NSNotification** curReach = [note ==
I added a Category -- Reachability (AutoChecker) for Apple's routine)
. H file:
+ ()startCheckWithReachability:(Reachability *+
. M file:
+ ()startCheckWithReachability:(Reachability **checker ===+*checker = (!=(networkStatus ==(networkStatus ==== kShouldPrintReachabilityFlags
Call method:
AppDelegate. m
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary * Reachability *pReachability = [Reachability reachabilityWithHostName:= self.viewController = [[ViewController alloc] initWithNibName:=
ViewController. m
- (IBAction)upInside_checkNetStatus:((!*alert = [[UIAlertView alloc] initWithTitle:
Run-Time reminder: # error "this class needs to be compiled in a non-arc environment. Please add the-fno-objc-arc flag"
The normal network NSLog is as follows:
14:15:53. 084 PRJ_reachability [8153: 11303] Reachability Flag Status:-R ------- networkStatusForFlags
14:15:54. 265 PRJ_reachability [8153: 11303] WIFI
14:15:54. 266 PRJ_reachability [8153: 11303] NetworkStatus 1 connectionRequired 0
PRJ_reachability.zip example: http://ishare.iask.sina.com.cn/f/37441462.html