Develop
2015.06.26 16:55
[ios] NSNotificationCenter 초간단 사용 예~ ㅋㄷ
Views 1852 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 |
---|---|---|---|---|---|
673 | Develop |
[ios] iOS 의 인앱구매 소개
![]() |
hooni | 2014.04.29 | 5252 |
672 | Develop |
[ios] iOS앱의 Xcode 빌드 과정
![]() |
hooni | 2015.01.03 | 3811 |
671 | Develop | [ios] iOS에서 디바이스 종류 알아오기 | hooni | 2014.05.24 | 4606 |
670 | Develop | [ios] iphone SetDeviceOrientation 화면 강제 회전 | hooni | 2013.11.20 | 20236 |
669 | Develop |
[ios] libxml/tree.h file not found
![]() |
hooni | 2013.08.08 | 21280 |
668 | Develop |
[ios] Locale Identifiers
![]() |
hooni | 2018.11.29 | 3717 |
667 | Develop | [ios] NavigationController 에서 왼쪽(back) 버튼 후킹하기 | hooni | 2015.10.23 | 4688 |
666 | Develop |
[ios] None IB vs. StoryBoard 샘플 소스
![]() |
hooni | 2013.09.06 | 19407 |
665 | Develop | [ios] NSData to NSString (NSString to NSData) | hooni | 2015.07.21 | 2023 |
664 | Develop | [ios] NSData 클래스에 대해 (NSData <-> char*) | hooni | 2013.04.23 | 27602 |
663 | Develop | [ios] NSMutableString 문자열 패턴 교환 | hooni | 2013.04.23 | 30106 |
» | Develop | [ios] NSNotificationCenter 초간단 사용 예~ ㅋㄷ | hooni | 2015.06.26 | 1852 |