Develop
2015.06.26 16:55
[ios] NSNotificationCenter 초간단 사용 예~ ㅋㄷ
조회 수 657 댓글 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 | [js] 키보드 아스키 코드 확인하는 간단한 소스 | hooni | 2003.04.23 | 7755 |
524 | Develop | [c#] HTML 이벤트 샘플 소스.. | hooni | 2013.04.23 | 7739 |
523 | Develop | [c#]뉴 툴바 개인적으로 만든거.. (new) | hooni | 2013.04.23 | 7724 |
522 | Develop | [doc] mfc 매뉴얼 다운 받아서 완성하기.. ㅋㄷ | hooni | 2013.04.23 | 7708 |
521 | Develop | [c] 프로그램 코드(c/c++)를 html 파일로 변환 | hooni | 2013.04.23 | 7677 |
520 | Develop | [c] 프로그래밍의 전반적인 설명 ppt | hooni | 2003.04.23 | 7675 |
519 | Develop | [linux] tar 명령어 뽀개기.. ㅋㅋ | hooni | 2003.04.23 | 7671 |
518 | Develop | [c] 관계형 연산자에 대한 설명 | hooni | 2013.04.23 | 7667 |
517 | Develop | [c] 구조체 배열 예제 (학생 성적 계산) | hooni | 2013.04.23 | 7667 |
516 | Develop | [c] 코드 최적화에 대해.. | hooni | 2013.04.23 | 7656 |
515 | Develop | [c#]업글 뉴 툴바 개인적으로 만든거.. (new) ㅋㅋ | hooni | 2013.04.23 | 7651 |
514 | Develop | [php] 자바스크립트 개판 만들기.. | hooni | 2013.04.23 | 7651 |