Views 654 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
309 Develop [c] 마우스 따라다니는 고양이 - 네코95 (WinAPI) file hooni 2013.04.23 7944
308 Develop [c] 로또(Lotto) 번호 생성기 file hooni 2013.04.23 7174
307 Develop [c] 레포트용으로 제출했던 여러 소스코드 모음 file hooni 2003.04.23 8084
306 Develop [c] 라인수 입력받아 마름모꼴 출력하기.. hooni 2003.04.23 6868
305 Develop [c] 디피-헬만 키교환(Diffie–Hellman key exchange) 샘플 코드.. ㅋㄷ file hooni 2013.04.23 9109
304 Develop [c] 도스 공격(DoS Attack) 프로그램 file hooni 2013.04.23 11575
303 Develop [c] 도메인(호스트)으로 IP정보 알아오기.. (nslookup과 비슷) file hooni 2013.04.23 6925
302 Develop [c] 도메인 소켓(Unix Domain Socket) UDP file hooni 2013.04.23 9282
301 Develop [c] 더블(이중) 연결리스트 예제.. file hooni 2013.04.23 7470
300 Develop [c] 달팽이 배열? 인지 먼지.. ㅋㅋ hooni 2013.04.23 7128
299 Develop [c] 단어 입력/수정 프로그램 소스 file hooni 2003.04.23 7014
298 Develop [c] 단기과정[01/24] 정렬 알고리즘 hooni 2003.04.23 6955
297 Develop [c] 단기과정[01/17] 후위연산 스택 계산기.. file hooni 2003.04.23 7226
296 Develop [c] 단기과정[01/15] 피보나치, 파스칼.. 링크리스트 file hooni 2003.04.23 7234
295 Develop [c] 단기과정[01/14] 피보나치, 파스칼.. 파일입출력 file hooni 2003.04.23 7081
294 Develop [c] 단기과정[01/14] 파일 입출력 file hooni 2003.04.23 6821
Board Pagination Prev 1 ... 53 54 55 56 57 ... 74 Next
/ 74