Contents

조회 수 673 댓글 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.05.24 CategoryDevelop Byhooni Views3673
    Read More
  2. [ios] iphone SetDeviceOrientation 화면 강제 회전

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

    Date2013.08.08 CategoryDevelop Byhooni Views18720
    Read More
  4. [ios] Locale Identifiers

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

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

    Date2013.09.06 CategoryDevelop Byhooni Views16950
    Read More
  7. [ios] NSData to NSString (NSString to NSData)

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

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

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

    Date2015.06.26 CategoryDevelop Byhooni Views673
    Read More
  11. [ios] NSString URL Encode/Decode (인코딩/디코딩)

    Date2014.05.02 CategoryDevelop Byhooni Views3430
    Read More
  12. [ios] NSString 간단한 정규식 사용법

    Date2014.01.28 CategoryDevelop Byhooni Views18225
    Read More
Board Pagination Prev 1 ... 38 39 40 41 42 43 44 45 46 47 ... 98 Next
/ 98