Develop
2015.06.26 16:55
[ios] NSNotificationCenter 초간단 사용 예~ ㅋㄷ
조회 수 756 댓글 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]; }
번호 | 분류 | 제목 | 글쓴이 | 날짜 | 조회 수 |
---|---|---|---|---|---|
1149 | Etc | 영어의 12 시제 (The twelve tenses of English) | hooni | 2013.07.12 | 15803 |
1148 | Etc | 영어공부에 도움될만한 사이트 모음 | hooni | 2013.05.14 | 22692 |
1147 | Etc | 영어. 외우면 도움되는 필수영어회화 표현 | hooni | 2013.09.09 | 21267 |
1146 | Etc | 영어. 불규칙 동사 정리 | hooni | 2017.10.04 | 3662 |
1145 | Etc | 영어. 반드시 외워야 할 영어 숙어 2 | hooni | 2016.07.07 | 6435 |
1144 | Etc | 영어. 반드시 외워야 할 문장 패턴 100개 | hooni | 2023.06.08 | 1417 |
1143 | Etc | 영어. 반드시 외워야 할 단어 | hooni | 2016.07.07 | 2083 |
1142 | Etc | 영어 아주 쉬운 영작문 강의 01~60 | hooni | 2013.06.25 | 0 |
1141 | Etc | 영어 관련 토렌트 | hooni | 2013.06.25 | 0 |
1140 | Etc | 여러 대학 및 권위있는 기관 강좌 모음 ㅋㅋ | hooni | 2013.06.17 | 15263 |
1139 | Etc | 여기저기서 모은 VoIP(인터넷전화) 자료들~ | hooni | 2013.04.23 | 16036 |
1138 | Etc | 엑셀 함수 총 정리 ㅎㅎ | hooni | 2013.06.05 | 24610 |