Develop
2015.06.26 16:55
[ios] NSNotificationCenter 초간단 사용 예~ ㅋㄷ
조회 수 657 댓글 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]; }
번호 | 분류 | 제목 | 글쓴이 | 날짜 | 조회 수 |
---|---|---|---|---|---|
37 | Develop | [php] 쉘에서 실행할 때 인수(파라미터) 받기.. | hooni | 2003.04.23 | 11595 |
36 | Develop | [js] 자바스크립트 이벤트 핸들.. | hooni | 2003.04.23 | 7908 |
35 | Develop | [css] 화면 스크롤 제어 ㅋㅋ | hooni | 2003.04.23 | 8681 |
34 | Develop | [php] 배열 관련 함수 설명 ㅎㅎ | hooni | 2003.04.23 | 11747 |
33 | Develop | [c++]현승이가 보내준 암호화 모듈 AES라인델.. | hooni | 2003.04.23 | 10715 |
32 | Develop | [c++]현승이가 보내준 동영상 암호화 자료.. 볼것.. | hooni | 2003.04.23 | 9729 |
31 | Develop | [php] 니우쪽지다.. 받아라~ ^^ | hooni | 2003.04.23 | 9835 |
30 | Develop | [c] 민수형 libipq 샘플 소스 ㅋㅋ | hooni | 2003.04.23 | 14113 |
29 | Develop | [css] 스크롤바 안생기게 | hooni | 2003.04.23 | 9887 |
28 | Develop | [c] 프로그래밍 ppt, 스킬업 (비트 수업자료) | hooni | 2003.04.23 | 8177 |
27 | Develop | [c++] p.118 확인학습 5번 | hooni | 2003.04.23 | 10734 |
26 | Develop | [c++] p.58 연습문제 2번 | hooni | 2003.04.23 | 16296 |