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

  • AmazonWireless

    AmazonWirele

    8 EYLÜL 2010
  • andony5589

    andony5589

    7 Aralık 2011
  • Ash100HD

    Ash100HD

    29 EKİM 2011