任何人都可以通过Reachability让我知道iphone设备是否连接到3G / Wifi。在这款iphone开发中,我可以获得一些示例/ URL的.im新内容。
提前致谢
答案 0 :(得分:1)
您可以尝试从Apple的Reachability示例开始 http://developer.apple.com/iphone/library/samplecode/Reachability/
答案 1 :(得分:0)
首先将SystemConfiguration.framework添加到您的项目
//Class.h
#import "Reachability.h"
#import <SystemConfiguration/SystemConfiguration.h>
- (BOOL)connected;
// Class.m
- (BOOL)connected
{
Reachability *reachability = [Reachability reachabilityForInternetConnection];
NetworkStatus networkStatus = [reachability currentReachabilityStatus];
return networkStatus != NotReachable;
}
Then, I use this whenever I want to see if I have a connection:
if (![self connected]) {
// Not connected
} else {
// Connected. Do some Internet stuff
}