SORU
9 Mayıs 2009, CUMARTESİ


Kakao Özel Bildirim Örneği

Biri bana nasıl ateş Kakao N-C nesne, özel bir bildirim ile, örnek göster, abone olmak, ve idare edebilir mi?

CEVAP
9 Mayıs 2009, CUMARTESİ


@implementation MyObject

// Posts a MyNotification message whenever called
- (void)notify {
  [[NSNotificationCenter defaultCenter] postNotificationName:@"MyNotification" object:self];
}

// Prints a message whenever a MyNotification is received
- (void)handleNotification:(NSNotification*)note {
  NSLog(@"Got notified: %@", note);
}

@end

// somewhere else
MyObject *object = [[MyObject alloc] init];
// receive MyNotification events from any object
[[NSNotificationCenter defaultCenter] addObserver:object selector:@selector(handleNotification:) name:@"MyNotification" object:nil];
// create a notification
[object notify];

Daha fazla bilgi için NSNotificationCenter belgelerine bakın.

Bunu Paylaş:
  • Google+
  • E-Posta
Etiketler:

YORUMLAR

SPONSOR VİDEO

Rastgele Yazarlar

  • MobileTechReview

    MobileTechRe

    6 HAZİRAN 2008
  • TomKNJ

    TomKNJ

    26 ŞUBAT 2007
  • Yo Mama

    Yo Mama

    18 EYLÜL 2005