If you want the app to pass the review, you must determine the network environment and handle alerts when there is no network.
Apple's routine reachability describes how to obtain/detect the network status. To be appliedProgramTo use Reachability in a program, you must first complete the following two parts:
1.1. Add the source file:
In your programUse ReachabilityYou only need to copy the reachability. h and reachability. m in this routine to your project. For example:
1. 2. Add the framework:
Set systemconfiguration. Framework Add to project. For example:
2. Network Status
Three Network statuses are defined in reachability. h:
Typedef Enum {
Notreachable = 0, // No connection
Reachableviawifi, // Use a 3G/GPRS network
Reachableviawwan // Use a Wi-Fi network
} Networkstatus;
Therefore, you can check the network status as follows:
Reachability * r = [reachability reachabilitywithhostname : @" Www.apple.com "];
Switch ([R currentreachabilitystatu S]) {
Case notreachable:
// No network connection
Break;
Case reachableviawwan:
// Use a 3G network
Break;
Case reachableviawifi:
// Use a Wi-Fi network
Bre AK;
}
Check: http://blog.sina.com.cn/s/blog_6f40a0e70100srip.html