Develop
2015.06.26 16:55
[ios] NSNotificationCenter 초간단 사용 예~ ㅋㄷ
조회 수 750 댓글 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]; }
-
[js] 스타크래프트(starcraft)..
-
[c] 웅지학원 NAT를 소스코드로..
-
[c] 간단한 점 이동 샘플 소스코드
-
[js] 새로고침(refresh)방법과 다른 페이지 바꾸기..
-
[c] 민수형 소스(도메인소켓포함)
-
[php] 정규표현식 간단히 정리
-
[c] 네트워크 보안 프로그래밍 과제 (Server,Agent,Client)
-
[c] 메세지 프로그램 (Server - Agent - Client)
-
[js] 윤동이가 만든 영어 학습(?) 프로그램
-
[doc] C언어 문법 설명서
-
[java] 채팅창 처럼2.. swing..
-
[c] 다중연결 서버 만들기 #3 - poll() 사용