Because the work is too busy in recent time, the blog has not been updated for some time, now to talk about the network judgment, if there are errors please the Great God can point out to learn together, thank you! Here's how it goes:
1. Add a source file (two): http://code4app.com/ios/Reachability/509743dc6803fae669000000
2. Import frame [systemconfiguration.framework]
3. Create a network connection
3.1 Creating an Internet Connection object
reachability *reach1 = [reachability reachabilityforinternetconnection];
3.2 Creating a local WiFi connection
reachability *REACH2 = [reachability Reachabilityforlocalwifi];
3.3 Creating a server network connection (important)
reachability *REACH3 = [reachability reachabilitywithhostname:@ "www.baidu.com"];
4. Judging the network
-(BOOL) isreachable; is available
-(BOOL) Isreachableviawwan; Whether Wwan is available
-(BOOL) Isreachableviawifi; Is WiFi available
5. Start notification
[Reach1 Startnotifier];
6. Registration Notice
Registration Notice
[[Nsnotificationcenter Defaultcenter] addobserver:self selector: @selector (networkchange:) Name: Kreachabilitychangednotification Object:nil];
7. Cancellation Notice
[[Nsnotificationcenter Defaultcenter] removeobserver:self name:kreachabilitychangednotification Object:nil];
How to make a network judgment on iOS