how to check internet connection through iphone or objective-c.???
Asked
Active
Viewed 204 times
0
-
Similar: http://stackoverflow.com/questions/1083701/how-to-check-for-an-active-internet-connection-on-iphone-sdk – miku Nov 26 '09 at 10:52
-
Duplicate of http://stackoverflow.com/questions/1802592/internet-problem/1802657 – Lee Nov 26 '09 at 11:02
4 Answers
2
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];
}

Vincent Osinga
- 1,043
- 7
- 15
0
Have a look at the apple sample code Reachability. It should provide you with everything you need.

Mick Walker
- 3,862
- 6
- 47
- 72