开发者

internet problem

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜