user177893
user177893

Reputation: 145

internet problem

how to check internet connection through iphone or objective-c.???

Upvotes: 0

Views: 211

Answers (4)

Vincent Osinga
Vincent Osinga

Reputation: 1039

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];
}

Upvotes: 2

Mick Walker
Mick Walker

Reputation: 3847

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

Upvotes: 0

prakash
prakash

Reputation: 59689

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

Upvotes: 0

Bobby
Bobby

Reputation: 11576

Quick and Drity: Ping Google?

Upvotes: 0

Related Questions