Develop
2015.06.26 16:55
[ios] NSNotificationCenter 초간단 사용 예~ ㅋㄷ
조회 수 659 댓글 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]; }
번호 | 분류 | 제목 | 글쓴이 | 날짜 | 조회 수 |
---|---|---|---|---|---|
313 | Develop | [ios] Objective-C에서 형식이 있는 문자열(Format Strings)에 사용할 수 있는 토큰들(Tokens) | hooni | 2013.04.23 | 18788 |
312 | Develop | [ios] Objective-C 특정 문자 찾아 제거하기 | hooni | 2013.04.23 | 28070 |
311 | Develop | [ios] Objective-C 문자열 잘라서 배열(NSArray)에 넣기 | hooni | 2013.04.23 | 29420 |
310 | Develop | [Xcode] 디버깅 옵션 | hooni | 2013.04.23 | 57201 |
309 | Develop | 웹페이지 성능 테스트 툴 설명 | hooni | 2013.04.23 | 27450 |
308 | Develop | [ios] 개발 기초 가이드 링크.. | hooni | 2013.04.23 | 31371 |
307 | Develop | 논문 실험용 고려대 툴바 ㅎㅎ | hooni | 2013.04.23 | 8686 |
306 | Develop | [ios] NSMutableString 문자열 패턴 교환 | hooni | 2013.04.23 | 28994 |
305 | Develop | [iphone] view에 대한 조사 ㅡ,.ㅡ; | hooni | 2013.04.23 | 54074 |
304 | Develop | [ios] 구분자로 문자열 자르기 (split) | hooni | 2013.04.23 | 26274 |
303 | Develop | [ios] 아이폰 개발 총정리.. | hooni | 2013.04.23 | 23868 |
302 | Develop | [ios] Debug Extensions (from 종길 차장님 ㅋㅋ) | hooni | 2013.04.23 | 17696 |