Develop
2015.06.26 16:55
[ios] NSNotificationCenter 초간단 사용 예~ ㅋㄷ
조회 수 659 댓글 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]; }
번호 | 분류 | 제목 | 글쓴이 | 날짜 | 조회 수 |
---|---|---|---|---|---|
441 | Develop | [node.js] nodejs 기본 설치 | hooni | 2013.04.23 | 26257 |
440 | Develop | [node.js] 지금 하고 있는거.. | hooni | 2013.04.23 | 26980 |
439 | Develop | [iphone] 파일 업로드 샘플 코드 ㅎㅎ | hooni | 2013.04.23 | 11120 |
438 | Develop | [js] JSON 컨트롤.. 재귀호출로 값 출력하기 | hooni | 2013.04.23 | 28641 |
437 | Develop | [js] 모바일웹에서 이미지 저장하는거 (context menu) 막기 | hooni | 2013.04.23 | 26372 |
436 | Develop | [android] keytool을 사용하여 키스토어 생성 | hooni | 2013.04.23 | 69516 |
435 | Develop | [js]모바일 웹에서 orientationchange | hooni | 2013.04.23 | 19361 |
434 | System/OS | 맥에서 파일공유 (윈도우,맥) | hooni | 2013.04.25 | 37306 |
433 | System/OS | [mysql] mysql user 생성시 ERROR 1364 | hooni | 2013.04.25 | 28509 |
432 | System/OS | Mac OS X - Apache+PHP+MySQL 환경 서버 | hooni | 2013.04.25 | 31631 |
431 | Etc | 영어공부에 도움될만한 사이트 모음 | hooni | 2013.05.14 | 22633 |
430 | Develop | 서기의 PHP 동영상 강의(싱싱해) | hooni | 2013.05.15 | 30984 |