Domanda

Come posso stampare ogni singola notifica sul mio sistema in obj-C?

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

quello che fa in "..."? Dovrei usare NSDistributedNotificationCenter?

Diciamo che ho una funzione chiamata logfunc che farà NSLog (@ "ok");

grazie

È stato utile?

Soluzione

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

You can then define a method that matches your selector, like this:

- (void)myMethod:(NSNotification *)notification {
    NSLog(@"notification received: %@", notification);
}
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top