Develop
2015.06.26 16:55
[ios] NSNotificationCenter 초간단 사용 예~ ㅋㄷ
조회 수 1865 댓글 0
Notification 날릴 때,
//Dictionary 만들어서 사용할 경우.. NSDictionary *infoData = [NSDictionary dictionaryWithObjectsAndKeys:missionIdString, @"missionId", winYNString, @"winYNString", str1String, @"str1String", str2String, @"str2String", callbackString, @"callbackString", nil]; [[NSNotificationCenter defaultCenter] postNotificationName:@"NotificationLoadedBenefitView" object:nil userInfo:infoData]; // 또는 한번에.. ㅋㄷ [[NSNotificationCenter defaultCenter] postNotificationName:@"NotificationLoadedBenefitView" object:nil userInfo:@{@"missionId":missionIdString, @"winYNString": winYNString, @"str1String": str1String, @"str2String": str2String, @"callbackString": callbackString}];
Notification 받는 방법과 처리하는 메소드(selector)
// Notification 처리 메소드 - (void)updateBenefitView:(NSNotification *)notification { self.isWithCallback = YES; [self viewMissionResult:notification]; NSDictionary *dict = [notification userInfo]; NSString *callbackString = [dict objectForKey:@"callbackString"]; [self performSelector:@selector(execCallback:) withObject:callbackString afterDelay:1.0]; } // Notification 옵저버 - (void)viewDidLoad { [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateBenefitView:) name:@"NotificationLoadedBenefitView" object:nil]; } // Notification 제거 - (void)dealloc { [[NSNotificationCenter defaultCenter] removeObserver:self]; }
번호 | 분류 | 제목 | 글쓴이 | 날짜 | 조회 수 |
---|---|---|---|---|---|
1141 | System/OS | [linux] 웹로그분석기(webalizer) 설치 & 팁 | hooni | 2003.04.23 | 16017 |
1140 | System/OS | [linux] 데스크탑환경(GNOME/KDE) 바꾸기.. | hooni | 2003.04.23 | 13259 |
1139 | System/OS | [linux] 센드메일 동적릴레이 설치 | hooni | 2003.04.23 | 16469 |
1138 | System/OS | HTTP 프로토콜 (브라우저와 웹서버 간의 통신) | hooni | 2003.04.23 | 50790 |
1137 | Database | [mysql] DB->Text, Text->DB 변환 | hooni | 2003.04.23 | 13420 |
1136 | System/OS | [windows] 패스워드를 잊어먹었을때.. | hooni | 2003.04.23 | 18496 |
1135 | System/OS | [bios] 시스템 부팅 도중 발생하는 비프음 | hooni | 2003.04.23 | 19399 |
1134 | System/OS | [unix] SUN Solaris 싱글모드.. ㅡ,.ㅡ; | hooni | 2003.04.23 | 13436 |
1133 | System/OS | [linux] ProFTPD 타임아웃 설정 | hooni | 2003.04.23 | 13958 |
1132 | Develop | [css] 스크롤바 안생기게 | hooni | 2003.04.23 | 11530 |
1131 | System/OS | [unix] 유닉스 csh에서 환경변수 등록 | hooni | 2003.04.23 | 12577 |
1130 | System/OS | [linux] 쉘 스크립트 (Shell Script) | hooni | 2003.04.23 | 13205 |