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]; }
-
[c] 코드 최적화에 대해..
-
[c] 콘솔에서 패스워드 입력시 문자 보이지 않게 하는 코드
-
[c] 퀵정렬(quick sort) 예제 소스..
-
[c] 테트리스(Tetris) 게임(도스용) 소스코드
-
[c] 테트리스3D (Tetris 3D)
-
[c] 텍스트 파일(로그)을 정해진 라인 단위로 쪼개주는 코드
-
[c] 파이프(popen)로 다른 프로세스 실행결과 가져오기
-
[c] 파일 복사(copy) 프로그램 샘플 소스
-
[c] 파일(File) 관련 함수 샘플 코드
-
[c] 파일(File)의 연결과 연결 해제 (link, unlink, chown)
-
[c] 파일(int fd)에서 개행문자 단위로 읽기 by 후리자
-
[c] 파일명 또는 특정 패턴을 적용