Contents

조회 수 1852 댓글 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
번호 분류 제목 글쓴이 날짜 조회 수
205 Develop [c#]뉴 툴바 개인적으로 만든거.. (old) secret hooni 2013.04.23 4272
204 Develop 알고리즘 성능분석 file hooni 2014.06.24 4264
203 System/OS 콘솔에서 패스워드 걸린 zip 압축하는 명령 hooni 2018.03.02 4262
202 Develop [ios] How To Use UIScrollView to Scroll and Zoom Content (Using Objective-C) file hooni 2016.03.23 4246
201 Develop [ios] 커스텀 폰트 사용하기 (Custom Fonts) file hooni 2014.04.30 4234
200 PPT [ppt] Macro for board game 발표자료 (@Team Study 2013.01.18) 1 file hooni 2015.07.22 4214
199 Develop [ios] Xcode에서 특정 파일만 ARC 따로 설정하는 방법 file hooni 2017.03.29 4201
198 Develop [ios] iOS 사운드 관련 프레임워크 hooni 2014.04.18 4175
197 Develop [io] Apple Watch, Today Extension 앱ID 설정 hooni 2016.04.20 4163
196 Develop [js] Array.splice() 설명 hooni 2014.04.24 4133
195 System/OS SSH Passwordless Login Using SSH Keygen in 5 Easy Steps file hooni 2019.11.22 4131
194 Develop [vim] vim 명령으로  문자 제거하기 (remove 65279 bomb) hooni 2021.02.03 4122
Board Pagination Prev 1 ... 77 78 79 80 81 82 83 84 85 86 ... 99 Next
/ 99