Develop
2015.06.26 16:55
[ios] NSNotificationCenter 초간단 사용 예~ ㅋㄷ
Views 654 Comment 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]; }
No. | Category | Subject | Author | Date | Views |
---|---|---|---|---|---|
841 | Develop | 프로그램 문서 관리 (Doxygen) | hooni | 2013.04.23 | 16385 |
840 | Develop | 프로그래밍에서 foo, bar 함수의 유래 | hooni | 2013.06.25 | 21255 |
839 | Develop | 프로그래밍 소스 관련 사이트.. | hooni | 2013.04.23 | 16485 |
838 | Develop | 페이팔에서 돈 찾기 (Paypal withdraw) | hooni | 2014.02.20 | 11374 |
837 | Develop | 캘리포니아 운전면허 족보 | hooni | 2017.06.12 | 736 |
836 | Develop | 최근 논문 자료 (2011/01/03, 만현형한테 보낸거..) | hooni | 2013.04.23 | 10366 |
835 | Develop | 참고하고 지울 자료.. 집에서 바야지.. ㅋㅋ | hooni | 2013.04.23 | 12123 |
834 | Develop | 정리할 자료. | hooni | 2015.07.02 | 677 |
833 | Develop | 자주 쓰는 Docker 명령어 alias | hooni | 2020.01.10 | 269373 |
832 | Develop | 이어서 작업할 내용~ | hooni | 2013.11.21 | 0 |
831 | Develop | 웹페이지 성능 테스트 툴 설명 | hooni | 2013.04.23 | 27445 |
830 | Develop | 알고리즘 성능분석 | hooni | 2014.06.24 | 2963 |