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

  • 3dmmfavs

    3dmmfavs

    29 Kasım 2009
  • RocketJump

    RocketJump

    22 ŞUBAT 2006
  • YouChewBu

    YouChewBu

    26 Ocak 2009