Contents

조회 수 1863 댓글 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
번호 분류 제목 글쓴이 날짜 조회 수
985 Develop [vim] vim 명령으로  문자 제거하기 (remove 65279 bomb) hooni 2021.02.03 4126
984 Develop [js] Array.splice() 설명 hooni 2014.04.24 4139
983 Develop [io] Apple Watch, Today Extension 앱ID 설정 hooni 2016.04.20 4174
982 System/OS [linux] wget 명령 사용 예제 hooni 2020.05.26 4178
981 Develop [ios] iOS 사운드 관련 프레임워크 hooni 2014.04.18 4181
980 Develop [ios] Xcode에서 특정 파일만 ARC 따로 설정하는 방법 file hooni 2017.03.29 4210
979 PPT [ppt] Macro for board game 발표자료 (@Team Study 2013.01.18) 1 file hooni 2015.07.22 4222
978 System/OS SSH Passwordless Login Using SSH Keygen in 5 Easy Steps file hooni 2019.11.22 4222
977 Develop [ios] 커스텀 폰트 사용하기 (Custom Fonts) file hooni 2014.04.30 4239
976 Develop [ios] How To Use UIScrollView to Scroll and Zoom Content (Using Objective-C) file hooni 2016.03.23 4259
975 System/OS 콘솔에서 패스워드 걸린 zip 압축하는 명령 hooni 2018.03.02 4267
974 Develop [c#]뉴 툴바 개인적으로 만든거.. (old) secret hooni 2013.04.23 4272
Board Pagination Prev 1 ... 12 13 14 15 16 17 18 19 20 21 ... 99 Next
/ 99