조회 수 753 추천 수 0 댓글 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
번호 분류 제목 글쓴이 날짜 조회 수
825 Develop [sh] 쉘스크립트 if 비교 연산 hooni 2020.05.26 60904
824 Develop [android] Canvas를 이용해 이미지 확대/축소 하기 hooni 2013.04.23 60791
823 Develop [vb] 비주얼 베이직 141페이지 hooni 2003.04.23 59009
822 Develop [c#] Json 라이브러리 (System.Net.Json.dll) file hooni 2013.04.23 58578
821 Develop [vb] 비주얼 베이직 순위 정렬 루틴 hooni 2003.04.23 58426
820 Develop [vb] 비주얼 베이직 131페이지 hooni 2003.04.23 58148
819 Develop [android] SurfaceView를 이용한 애니메이션 ㅎㅎ file hooni 2013.04.23 57763
818 Develop 레고 NXT 마인드스톰 밸런싱 로봇 ㅎㅎ file hooni 2013.04.23 57761
817 Develop [Xcode] 디버깅 옵션 file hooni 2013.04.23 57253
816 Develop [vb] 비주얼 베이직 205페이지 hooni 2003.04.23 56134
815 Develop [vb] 비쥬얼 베이직 기출 문제 연습 hooni 2003.04.23 55233
814 Develop [vb] 비주얼 베이직 173페이지 hooni 2003.04.23 54911
813 Develop [vb] 비쥬얼 베이직 기출 문제 연습2 hooni 2003.04.23 54442
812 Develop [iphone] view에 대한 조사 ㅡ,.ㅡ; file hooni 2013.04.23 54110
811 Develop [vb] 비쥬얼 베이직으로.. hooni 2003.04.23 53121
810 Develop [android] GCM 사용하기 1 (GCM 서비스 신청하기) file hooni 2013.07.06 51421
Board Pagination Prev 1 2 3 4 5 ... 53 Next
/ 53