开发者

internet problem

开发者 https://www.devze.com 2022-12-12 08:51 出处:网络
how to check internet connection开发者_开发技巧 through iphoneorobjective-c.???Here is a code snippet you can use:

how to check internet connection开发者_开发技巧 through iphone or objective-c.???


Here is a code snippet you can use:

[[Reachability sharedReachability] setHostName:@"example.com"];
if ([[Reachability sharedReachability] remoteHostStatus] == NotReachable) {
    UIAlertView *dialog = [[[UIAlertView alloc] init] retain];
    [dialog setTitle:@"Server unreachable"];
    [dialog setMessage:@"The server is temporarily unavailable."];
    [dialog addButtonWithTitle:@"OK"];
    [dialog show];
    [dialog release];
}


Quick and Drity: Ping Google?


Apple's recommendation is to do something like (or use) Reachability


Have a look at the apple sample code Reachability. It should provide you with everything you need.

0

精彩评论

暂无评论...
验证码 换一张
取 消