[英]How to find whether iphone device connected to 3G /Wifi using Reachability
誰能讓我知道是否使用Reachability連接到3G / Wifi的iPhone設備。請給我一些此iPhone開發中的示例/ URL的.im。
提前致謝
您可以嘗試從Apple http://developer.apple.com/iphone/library/samplecode/Reachability/的Rechability示例開始
首先將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
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.