Contents

조회 수 654 댓글 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
번호 분류 제목 글쓴이 날짜 조회 수
57 System/OS [ms-sql] 서브스트링(substring), 프로시저(SP) 작성 예제 hooni 2013.04.23 41296
56 System/OS [linux] 네트웍 트래픽 모니터링(MRTG) hooni 2003.04.23 41746
55 Etc [용어] POC, Pilot, BMT에 대한 IT 업계에서 통용되는 의미 hooni 2014.01.02 41949
54 Develop [java] 스트러츠(Struts) 세팅 ㅋㅋ file hooni 2013.04.23 42351
53 Develop [ios] 미스터피자(Mr.pizza) 어플 file hooni 2013.04.23 42631
52 Develop [c++] BHO 프로그램 동작 원리.. 간단하게.. hooni 2013.04.23 43093
51 Develop [android] 화면 전환(가로/세로)시 설정 hooni 2013.04.23 43369
50 Develop [android] ListView+ArrayAdapter 테스트 hooni 2013.04.23 43897
49 Etc 스파이웨어(BHO) 탐지하는 방법.. hooni 2013.04.23 44400
48 Develop [android] ArrayAdapter 테스트 파일 ㅎㅎ hooni 2013.04.23 45239
47 Develop [ios] 배열(NSArray) 연산과 간단한 애니메이션(split images) hooni 2013.10.31 45436
46 Develop [ios] UIAlertView 초간단 샘플 ㅎㅎ hooni 2013.10.14 46106
Board Pagination Prev 1 ... 89 90 91 92 93 94 95 96 97 98 Next
/ 98