任何人都可以让我知道是否使用 Reachability 连接到 3G/Wifi 的 iphone 设备。请给我一些示例/URL 的 .im 在这个 iphone 开发中是新的。
提前致谢
任何人都可以让我知道是否使用 Reachability 连接到 3G/Wifi 的 iphone 设备。请给我一些示例/URL 的 .im 在这个 iphone 开发中是新的。
提前致谢
首先将 SystemConfiguration.framework 添加到您的项目中
//Class.h
#import "Reachability.h"
#import <SystemConfiguration/SystemConfiguration.h>
- (BOOL)connected;
//类.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
}