1 프로젝트에 SystemConfiguration.framework
를 추가 할 수 있습니다. GitHub
Reachability.h
Reachability.m
3에서
2 개 다운로드 다음 파일 변수 Reachability* internetReachable;
YourViewController.h
에 추가
4- YourViewController.h
#import <UIKit/UIKit.h>
@class Reachability;
5에 @class Reachability;
를 추가 프로젝트에서 이러한 파일을 추가
#import <UIKit/UIKit.h>
@class Reachability;
@interface YourViewController : UIViewController {
Reachability* internetReachable;
}
6 이제까지 이제 -(void)viewDidLoad
-(void) checkNetworkStatus:(NSNotification *)notice
{
// called after network status changes
NetworkStatus internetStatus = [internetReachable currentReachabilityStatus];
switch (internetStatus)
{
case NotReachable:
{
NSLog(@"The internet is down.");
break;
}
case ReachableViaWiFi:
{
NSLog(@"The internet is working via WIFI.");
break;
}
case ReachableViaWWAN:
{
NSLog(@"The internet is working via WWAN.");
break;
}
}
}
후 기능 다음 YourViewController.m
-(void)ViewDidLoad {
[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector(checkNetworkStatus:)
name:kReachabilityChangedNotification
object:nil];
internetReachable = [Reachability reachabilityForInternetConnection];
[internetReachable startNotifier];
}
8 추가에 -(void)ViewDidLoad
에서 YourViewController.m
#import "YourViewController.h"
#import "Reachability.h"
7- 추가 다음 줄에 Reachability.h
추가 y 인터넷 연결 변경으로 콘솔에 로그인 할 수 있습니다.
가능한 복제본 : http://stackoverflow.com/questions/784582/easiest-way-to-determine-whether-iphone-internet-connection-is-available – 0x8badf00d