Views 656 Votes 0 Comment 0
?

Shortcut

PrevPrev Article

NextNext Article

Larger Font Smaller Font Up Down Go comment Print
?

Shortcut

PrevPrev Article

NextNext Article

Larger Font Smaller Font Up Down Go comment Print

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
No. Category Subject Author Date Views
917 Develop [c] 간단한 소켓 프로그래밍 샘플 file hooni 2013.04.23 8162
916 Develop [c] 간단한 순위 루틴.. (정보처리기사) hooni 2003.04.23 6874
915 Develop [c] 간단한 순위 루틴.. (질문에 대한 답변) hooni 2003.04.23 7469
914 Develop [c] 간단한 자료구조(stack, queue, linked list) 구현 소스 6 file hooni 2003.04.23 10118
913 Develop [c] 간단한 점 이동 샘플 소스코드 hooni 2013.04.23 6542
912 Develop [c] 간단한 채팅(클라이언트/서버) 프로그램 소스 file hooni 2003.04.23 9068
911 Develop [c] 거리와 각도를 입력받아서 좌표로 변환 file hooni 2013.04.23 10814
910 Develop [c] 게임 AI FSM 테스트 샘플 소스.. 꽤 괜찮은 소스.. file hooni 2013.04.23 7370
909 Develop [c] 격자 직사각형 넓이 구하기 file hooni 2013.04.23 7457
908 Develop [c] 공용체를 이용해 MSB를 LSB로 변환 file hooni 2013.04.23 9376
907 Develop [c] 관계형 연산자에 대한 설명 hooni 2013.04.23 7667
906 Develop [c] 구구단 최단라인 ㅡㅡ; file hooni 2013.04.23 8004
905 Develop [c] 구조체 배열 예제 (학생 성적 계산) file hooni 2013.04.23 7667
904 Develop [c] 구조체/파일 입출력 프로그램 file hooni 2003.04.23 7063
903 Develop [c] 구조체의 설명과 예제.. hooni 2003.04.23 8373
902 Develop [c] 그래픽 차트 라이브러리.. 나중에 확인 해볼 거.. file hooni 2013.04.23 8225
Board Pagination Prev 1 ... 15 16 17 18 19 ... 74 Next
/ 74