Notificaciones de impresión
-
22-10-2019 - |
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
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