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]; }
번호 | 분류 | 제목 | 글쓴이 | 날짜 | 조회 수 |
---|---|---|---|---|---|
525 | Develop | 다운 받아서 테스트 해볼것.. | hooni | 2013.04.23 | 9173 |
524 | Develop | [c] 하노이탑 - 재귀함수 | hooni | 2003.04.23 | 9178 |
523 | System/OS | [linux] 간단한 find 명령어 설명(업데이트 해야 함) | hooni | 2013.04.23 | 9181 |
522 | Develop | [c][java] 그래픽(graphic)관련 자료와 샘플코드.. | hooni | 2013.04.23 | 9218 |
521 | Develop | [php] URL/URI 관련 환경변수 | hooni | 2003.04.23 | 9220 |
520 | Develop | [c] SetTimer() & KillTimer() & 일회용 Timer | hooni | 2013.04.23 | 9241 |
519 | Develop | [c++] RSA Sample 4 CPP | hooni | 2013.04.23 | 9247 |
518 | Develop | [c++] mfc이용한 트레이아이콘(TrayIcon) 클래스 예제 프로젝트 | hooni | 2013.04.23 | 9275 |
517 | Develop | [ios] In App Purchase 개발 | hooni | 2013.11.20 | 9302 |
516 | Develop | [c] 도메인 소켓(Unix Domain Socket) UDP | hooni | 2013.04.23 | 9314 |
515 | Develop | [c] 전위 표기법으로 연산 예제.. | hooni | 2013.04.23 | 9322 |
514 | Develop | [js] 폼(form) 전송시 중복 클릭 방지 간단한 구문 | hooni | 2013.04.23 | 9329 |