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.
精彩评论