Question

Comment puis-je imprimer chaque seule notification sur mon système en Obj-C?

[[NSNotificationCenter defaultCenter] addObserver:self ...];

qu'est-ce que dans "..."? Dois-je utiliser NSDistributedNotificationCenter?

Disons que j'ai une fonction appelée logfunc qui fera NSLog (@ "ok");

Merci

Était-ce utile?

La solution

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(myMethod:) name:nil object:nil];

Vous pouvez alors définir une méthode qui correspond à votre sélection, comme ceci:

- (void)myMethod:(NSNotification *)notification {
    NSLog(@"notification received: %@", notification);
}
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top