将Reachability.h 和 Reachability.m 加到自己的项目中,并引用 SystemConfiguration.framework,就可以使用了。
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{
if (([Reachability reachabilityForInternetConnection].currentReachabilityStatus==NotReachable)||([Reachability reachabilityForLocalWiFi].currentReachabilityStatus==NotReachable))
{
UIAlertView *alert=[[UIAlertView alloc]initWithTitle:@"警告" message:@"您的设备暂时没有可用的网络!" delegate:self cancelButtonTitle:@"确定" otherButtonTitles: nil];
[alert show];
[alert release];
}
}