Develop
2015.06.26 16:55
[ios] NSNotificationCenter 초간단 사용 예~ ㅋㄷ
조회 수 652 댓글 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]; }
번호 | 분류 | 제목 | 글쓴이 | 날짜 | 조회 수 |
---|---|---|---|---|---|
733 | Develop | [ios] 최상위 ViewController 가져오기 | hooni | 2015.10.12 | 1044 |
732 | Develop | DDay Memo 1.9.4 소스코드 | hooni | 2015.10.03 | 0 |
731 | Develop | [ios] How to set up clang formatter | hooni | 2015.09.17 | 1342 |
730 | Develop | [ios] SBCampanion App 초안 | hooni | 2015.09.16 | 638 |
729 | Develop | [git] 쉬운 버전관리 Git 설명 | hooni | 2015.08.18 | 856 |
728 | Develop | [ios] 오브젝티브C→스위프트, 코드 변환 손쉽게 | hooni | 2015.08.07 | 942 |
727 | Develop | [ios] Objective-C Types & Storage Capacity | hooni | 2015.07.22 | 1138 |
726 | Develop | [ios] AES256 알고리즘을 이용해 데이터 암호화/복호화 방법 | hooni | 2015.07.21 | 4086 |
725 | Develop | [ios] NSData to NSString (NSString to NSData) | hooni | 2015.07.21 | 619 |
724 | Develop | [ios] WWDC 2015 샘플 소스 코드 통합파일 | hooni | 2015.07.20 | 644 |
723 | Develop | [android] N-Puzzle 게임 | hooni | 2015.07.09 | 850 |
722 | Develop | [android] 코드에서 문자열로 Resource 가져오기 | hooni | 2015.07.09 | 3925 |