Develop
2015.06.26 16:55
[ios] NSNotificationCenter 초간단 사용 예~ ㅋㄷ
조회 수 1852 댓글 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]; }
번호 | 분류 | 제목 | 글쓴이 | 날짜 | 조회 수 |
---|---|---|---|---|---|
529 | Develop |
[c++] 더블 링크리스트(linked list) 학습용 초간단 단어장
![]() |
hooni | 2003.04.23 | 10461 |
528 | Develop | [java] Sieve of Eratosthenes (에라토스테네스의 체) | hooni | 2013.04.23 | 10464 |
527 | Etc |
[english] 영어공부 혼자 하기, 인터넷으로 영어공부하기 추천사이트 20선
![]() |
hooni | 2013.11.25 | 10521 |
526 | Develop |
[c] 이진트리(binary tree)의 특성
![]() |
hooni | 2003.04.23 | 10555 |
525 | Develop | [js] Closure를 이용해 캡슐화.. | hooni | 2013.12.16 | 10570 |
524 | Develop |
[c++] 마방진 소스코드
![]() |
hooni | 2013.04.23 | 10571 |
523 | Develop |
[java] 거스름돈 계산.. swing 사용
![]() |
hooni | 2013.04.23 | 10657 |
522 | Develop | [c] 하노이탑 - 재귀함수 | hooni | 2003.04.23 | 10705 |
521 | Develop |
[doc] 유료 방송 제어 시스템 (CAS) 발표자료
![]() |
hooni | 2013.04.23 | 10748 |
520 | Develop |
[c] 오목.. 간단한 소스 ㅋㅋ
![]() |
hooni | 2013.04.23 | 10763 |
519 | Develop | [c] SetTimer() & KillTimer() & 일회용 Timer | hooni | 2013.04.23 | 10797 |
518 | Develop |
[c][java] 그래픽(graphic)관련 자료와 샘플코드..
![]() |
hooni | 2013.04.23 | 10799 |