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
501 Develop [js] AngularJS 란? file hooni 2015.11.26 890
500 Develop [js] AngularJS를 소개합니다. file hooni 2014.01.06 13014
499 Develop [js] Array.splice() 설명 hooni 2014.04.24 3003
498 Develop [js] Click button copy to clipboard hooni 2018.04.05 1173
497 Develop [js] Closure를 이용해 캡슐화.. hooni 2013.12.16 9594
496 Develop [js] e.stopPropagation() VS e.preventDefault () file hooni 2015.04.14 810
495 Develop [js] get방식, url이후 모두 그대로 읽어오기.. hooni 2013.04.23 6841
494 Develop [js] IE에서 인쇄 설정 팁 hooni 2013.04.23 10899
493 Develop [js] Javascript로 만든 포트리스 (2010) 5 file hooni 2017.03.03 2541
492 Develop [js] jQjuery $ 활용 hooni 2013.12.17 8874
491 Develop [js] jQuery 배열 루프(each) hooni 2013.12.17 9987
490 Develop [js] jQuery plugin 요약 hooni 2013.12.20 10700
489 Develop [js] jQuery 관련 문서 ㅎㅎ file hooni 2013.04.23 31225
488 Develop [js] jQuery 관련 사이트 링크 모음 hooni 2013.04.23 18241
487 Develop [js] jQuery 셀 병합 1 file hooni 2014.09.23 3492
486 Develop [js] jQuery 셀랙터(selector) 요약 hooni 2013.12.17 9418
Board Pagination Prev 1 ... 41 42 43 44 45 ... 74 Next
/ 74