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]; }
번호 | 분류 | 제목 | 글쓴이 | 날짜 | 조회 수 |
---|---|---|---|---|---|
669 | Etc | [english] 영어공부 혼자 하기, 인터넷으로 영어공부하기 추천사이트 20선 | hooni | 2013.11.25 | 9459 |
668 | Develop | [java] 스윙(swing)버튼 테스트 ㅋㅋ | hooni | 2013.04.23 | 9448 |
667 | Develop | [js] jQuery 셀랙터(selector) 요약 | hooni | 2013.12.17 | 9439 |
666 | Develop | [c] 공용체를 이용해 MSB를 LSB로 변환 | hooni | 2013.04.23 | 9390 |
665 | Develop | [php] Laravel 5.4: Specified key was too long error | hooni | 2017.12.04 | 9379 |
664 | Develop | [c] 다중연결 서버 만들기 #2 - select() 사용 | hooni | 2013.04.23 | 9378 |
663 | Develop | [c++] MFC로 만든 디렉토리/파일 파인더 | hooni | 2013.04.23 | 9367 |
662 | Develop | [c++] 더블 링크리스트(linked list) 학습용 초간단 단어장 | hooni | 2003.04.23 | 9367 |
661 | Develop | [java] Sieve of Eratosthenes (에라토스테네스의 체) | hooni | 2013.04.23 | 9349 |
660 | Develop | [js] 폼(form) 전송시 중복 클릭 방지 간단한 구문 | hooni | 2013.04.23 | 9329 |
659 | Develop | [c] 전위 표기법으로 연산 예제.. | hooni | 2013.04.23 | 9322 |
658 | Develop | [c] 도메인 소켓(Unix Domain Socket) UDP | hooni | 2013.04.23 | 9314 |