Develop
2015.06.26 16:55
[ios] NSNotificationCenter 초간단 사용 예~ ㅋㄷ
조회 수 652 댓글 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]; }
번호 | 분류 | 제목 | 글쓴이 | 날짜 | 조회 수 |
---|---|---|---|---|---|
745 | Develop | [c] 시간 관련 함수 설명과 예제.. | hooni | 2003.04.23 | 11518 |
744 | Develop | [c] 스토리지 클래스(변수) | hooni | 2003.04.23 | 8197 |
743 | Develop | [c] 포인터와 함수포인터에 대해.. | hooni | 2003.04.23 | 8019 |
742 | Develop | [c] 구조체의 설명과 예제.. | hooni | 2003.04.23 | 8373 |
741 | Develop | [c] 프로세스간의 통신(파이프) | hooni | 2003.04.23 | 6891 |
740 | Develop | [jsp] 정적/동적(차트생성) 이미지 전달 | hooni | 2003.04.23 | 7307 |
739 | Develop | [c] OpenGL 직사각형(2D) 크기 확대/축소 | hooni | 2003.04.23 | 9069 |
738 | Develop | [c++] 더블 링크리스트(linked list) 학습용 초간단 단어장 | hooni | 2003.04.23 | 9323 |
737 | Develop | [c] 구조체/파일 입출력 프로그램 | hooni | 2003.04.23 | 7063 |
736 | Develop | [c] 컴파일러 선행처리기 따라하기.. | hooni | 2003.04.23 | 6681 |
735 | Develop | [c] 싱글, 더블 링크리스트(linked list)로 만든 예제.. | hooni | 2003.04.23 | 6737 |
734 | Develop | [c] fgets() 함수 사용하기.. | hooni | 2003.04.23 | 7818 |