[아이폰] 인터넷 연결 확인
iOS2010. 1. 22. 11:40
첨부 파일의 예제로 인터넷은 연결과 연결 상태에 대하여 알 수 있습니다.
프로그램에는 Reachability.h, Reachability.m 파일들만 추가하여 사용하면 됩니다.
간당히 인터넷에 연결 유무만을 확인할 경우 아래와 같이 사용함.
- (void) showStatusReachability: (Reachability*) curReach {
NetworkStatus netStatus = [curReach currentReachabilityStatus];
switch (netStatus)
{
case NotReachable:
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"알림" message:@"인터넷에 연결되지 않았습니다." delegate:nil cancelButtonTitle:@"확인" otherButtonTitles:nil];
[alert show];
[alert release];
break;
}
}
}
- (void)applicationDidFinishLaunching:(UIApplication *)application {
//인터넷 연결 확인
internetReach = [[Reachability reachabilityForInternetConnection] retain];
[internetReach startNotifer];
[self showStatusReachability: internetReach];
[window addSubview:tabBarController.view];
}
프로그램에는 Reachability.h, Reachability.m 파일들만 추가하여 사용하면 됩니다.
간당히 인터넷에 연결 유무만을 확인할 경우 아래와 같이 사용함.
- (void) showStatusReachability: (Reachability*) curReach {
NetworkStatus netStatus = [curReach currentReachabilityStatus];
switch (netStatus)
{
case NotReachable:
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"알림" message:@"인터넷에 연결되지 않았습니다." delegate:nil cancelButtonTitle:@"확인" otherButtonTitles:nil];
[alert show];
[alert release];
break;
}
}
}
- (void)applicationDidFinishLaunching:(UIApplication *)application {
//인터넷 연결 확인
internetReach = [[Reachability reachabilityForInternetConnection] retain];
[internetReach startNotifer];
[self showStatusReachability: internetReach];
[window addSubview:tabBarController.view];
}
'iOS' 카테고리의 다른 글
| [iOS] 이미지 합치기(Image Merge) (0) | 2011.07.01 |
|---|---|
| [iOS] NSString Encoding (0) | 2011.07.01 |
| [iOS] NSString(문자열) 클래스 이름으로 부터 해당 클래스 객체 생성하기 (0) | 2011.03.09 |
| [iOS] 로그(NSLog) 기록 (0) | 2011.01.17 |
| [아이폰] "누구니?" 두둥! 최초 유료어플 등록 (0) | 2010.04.16 |
| [아이폰] 깊은 뮤터블 복사(mutableCopy) (5) | 2010.01.27 |
| iPod touch인지 iPhone 인지 구분하기 (0) | 2010.01.22 |
| 날짜(NSDate)를 원하는 포멧의 문자형태(NSString)로 받기 (0) | 2010.01.22 |
| View의 이동에 애니메이션 효과 주기 (0) | 2010.01.22 |
| 로딩이미지(Default.png) 애니메이션 주기 (1) | 2010.01.22 |
Reachability.zip