0

任何人都可以让我知道是否使用 Reachability 连接到 3G/Wifi 的 iphone 设备。请给我一些示例/URL 的 .im 在这个 iphone 开发中是新的。

提前致谢

4

2 回答 2

1

您可以尝试从 Apple http://developer.apple.com/iphone/library/samplecode/Reachability/的 Rechability 示例开始

于 2010-12-23T04:09:49.480 回答
0

首先将 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
}
于 2016-03-02T09:24:25.113 回答