2009-11-26 88 views
0

如何通過iphone或objective-c檢查互聯網連接?互聯網問題

+0

類似:http://stackoverflow.com/questions/1083701/how-to-check-for-an-active-internet-connection-on -iphone-sdk – miku 2009-11-26 10:52:59

+0

重複http://stackoverflow.com/questions/1802592/internet-problem/1802657 – Lee 2009-11-26 11:02:27

回答

0

Quick and Drity:Ping Google?

0

看一看蘋果的示例代碼可達性。它應該爲你提供你需要的一切。

2

下面的代碼片段,您可以使用:

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