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]; }
번호 | 분류 | 제목 | 글쓴이 | 날짜 | 조회 수 |
---|---|---|---|---|---|
229 | Develop | [c++] 인라인 함수 설명과 예제.. | hooni | 2013.04.23 | 6633 |
228 | Develop | [c] 웅지학원 NAT를 소스코드로.. | hooni | 2013.04.23 | 6611 |
227 | Develop | [c] 간단한 점 이동 샘플 소스코드 | hooni | 2013.04.23 | 6546 |
226 | Develop | [c] 민수형 소스(도메인소켓포함) | hooni | 2013.04.23 | 6522 |
225 | Develop | [js] 새로고침(refresh)방법과 다른 페이지 바꾸기.. | hooni | 2003.04.23 | 6521 |
224 | Develop | [c] 네트워크 보안 프로그래밍 과제 (Server,Agent,Client) | hooni | 2013.04.23 | 6473 |
223 | Develop | [js] 윤동이가 만든 영어 학습(?) 프로그램 | hooni | 2013.04.23 | 6464 |
222 | Develop | [c] 메세지 프로그램 (Server - Agent - Client) | hooni | 2013.04.23 | 6461 |
221 | Develop | [php] 정규표현식 간단히 정리 | hooni | 2013.04.23 | 6457 |
220 | Develop | [doc] C언어 문법 설명서 | hooni | 2013.04.23 | 6437 |
219 | Develop | [java] 채팅창 처럼2.. swing.. | hooni | 2013.04.23 | 6423 |
218 | Develop | [c] 다중연결 서버 만들기 #3 - poll() 사용 | hooni | 2013.04.23 | 6342 |