Pregunta

¿Cómo puedo imprimir todas las notificaciones en mi sistema en OBJ-C?

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

¿Qué hace en "..."? ¿Debo usar NSDistributedNotificationCenter?

Digamos que tengo una función llamada logFunc que hará nslog (@"ok");

gracias

¿Fue útil?

Solución

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

Luego puede definir un método que coincida con su selector, así:

- (void)myMethod:(NSNotification *)notification {
    NSLog(@"notification received: %@", notification);
}
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top