Contents

조회 수 1863 댓글 0
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄

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];
}

 


?

List of Articles
번호 분류 제목 글쓴이 날짜 조회 수
1033 Develop [matlab] 정보은닉 스테가노그래피(Steganography) 수업 file hooni 2016.10.03 2723
1032 Develop [c] RSA 암호화 구현(gmp 라이브러리 활용) file hooni 2016.10.03 2751
1031 Develop [c] Mac OS 에 gmp(gmp.h) 라이브러리 설치 hooni 2016.10.03 5064
1030 Develop [c] 셀프 넘버(Self Number) 구하기 1 hooni 2016.09.09 3833
1029 PPT 삼성페이(Samsung Pay) 구조 file hooni 2016.09.09 2802
1028 Develop [android] Android N requires the IDE to be running with Java 1.8 or later 오류 hooni 2016.08.30 2788
1027 Develop [c] 파일명 또는 특정 패턴을 적용 file hooni 2016.08.03 2412
1026 Develop [ios] Crashlytics, Fabfic 설치/설정 hooni 2016.07.21 2367
1025 Develop [ios] 새로 만들고 있는 DateMemo file hooni 2016.07.12 1903
1024 Etc 영어. 반드시 외워야 할 영어 숙어 2 file hooni 2016.07.07 8112
1023 Etc 영어. 반드시 외워야 할 단어 file hooni 2016.07.07 4004
1022 Develop [ios][swift] 초간단 카달로그 앱 (Catalog App) file hooni 2016.06.27 14312
Board Pagination Prev 1 ... 8 9 10 11 12 13 14 15 16 17 ... 99 Next
/ 99