Contents

조회 수 1851 댓글 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];
}

 


?

  1. [ios] iOS 의 인앱구매 소개

    Date2014.04.29 CategoryDevelop Byhooni Views5251
    Read More
  2. [ios] iOS앱의 Xcode 빌드 과정

    Date2015.01.03 CategoryDevelop Byhooni Views3807
    Read More
  3. [ios] iOS에서 디바이스 종류 알아오기

    Date2014.05.24 CategoryDevelop Byhooni Views4605
    Read More
  4. [ios] iphone SetDeviceOrientation 화면 강제 회전

    Date2013.11.20 CategoryDevelop Byhooni Views20236
    Read More
  5. [ios] libxml/tree.h file not found

    Date2013.08.08 CategoryDevelop Byhooni Views21280
    Read More
  6. [ios] Locale Identifiers

    Date2018.11.29 CategoryDevelop Byhooni Views3712
    Read More
  7. [ios] NavigationController 에서 왼쪽(back) 버튼 후킹하기

    Date2015.10.23 CategoryDevelop Byhooni Views4688
    Read More
  8. [ios] None IB vs. StoryBoard 샘플 소스

    Date2013.09.06 CategoryDevelop Byhooni Views19406
    Read More
  9. [ios] NSData to NSString (NSString to NSData)

    Date2015.07.21 CategoryDevelop Byhooni Views2022
    Read More
  10. [ios] NSData 클래스에 대해 (NSData <-> char*)

    Date2013.04.23 CategoryDevelop Byhooni Views27602
    Read More
  11. [ios] NSMutableString 문자열 패턴 교환

    Date2013.04.23 CategoryDevelop Byhooni Views30106
    Read More
  12. [ios] NSNotificationCenter 초간단 사용 예~ ㅋㄷ

    Date2015.06.26 CategoryDevelop Byhooni Views1851
    Read More
Board Pagination Prev 1 ... 38 39 40 41 42 43 44 45 46 47 ... 99 Next
/ 99