NSUserDefaults.Notifications.ObserveDidChange Método
Definición
Importante
Parte de la información hace referencia a la versión preliminar del producto, que puede haberse modificado sustancialmente antes de lanzar la versión definitiva. Microsoft no otorga ninguna garantía, explícita o implícita, con respecto a la información proporcionada aquí.
Sobrecargas
ObserveDidChange(EventHandler<NSNotificationEventArgs>) |
Notificación fuertemente tipada para la DidChangeNotification constante. |
ObserveDidChange(NSObject, EventHandler<NSNotificationEventArgs>) |
Notificación fuertemente tipada para la DidChangeNotification constante. |
ObserveDidChange(EventHandler<NSNotificationEventArgs>)
Notificación fuertemente tipada para la DidChangeNotification constante.
public static Foundation.NSObject ObserveDidChange (EventHandler<Foundation.NSNotificationEventArgs> handler);
static member ObserveDidChange : EventHandler<Foundation.NSNotificationEventArgs> -> Foundation.NSObject
Parámetros
- handler
- EventHandler<NSNotificationEventArgs>
Método para invocar cuando se publica la notificación.
Devoluciones
Objeto de token que se puede usar para dejar de recibir notificaciones al eliminarlo o pasarlo a RemoveObservers(IEnumerable<NSObject>)
Comentarios
Este método se puede usar para suscribirse DidChangeNotification a las notificaciones.
// Listen to all notifications posted for any object
var token = NSUserDefaults.Notifications.ObserveDidChange ((notification) => {
Console.WriteLine ("Observed DidChangeNotification!");
};
// Listen to all notifications posted for a single object
var token = NSUserDefaults.Notifications.ObserveDidChange (objectToObserve, (notification) => {
Console.WriteLine ($"Observed DidChangeNotification for {nameof (objectToObserve)}!");
};
// Stop listening for notifications
token.Dispose ();
Se aplica a
ObserveDidChange(NSObject, EventHandler<NSNotificationEventArgs>)
Notificación fuertemente tipada para la DidChangeNotification constante.
public static Foundation.NSObject ObserveDidChange (Foundation.NSObject objectToObserve, EventHandler<Foundation.NSNotificationEventArgs> handler);
static member ObserveDidChange : Foundation.NSObject * EventHandler<Foundation.NSNotificationEventArgs> -> Foundation.NSObject
Parámetros
- objectToObserve
- NSObject
Objeto que se va a observar.
- handler
- EventHandler<NSNotificationEventArgs>
Método para invocar cuando se publica la notificación.
Devoluciones
Objeto de token que se puede usar para dejar de recibir notificaciones al eliminarlo o pasarlo a RemoveObservers(IEnumerable<NSObject>)
Comentarios
Este método se puede usar para suscribirse DidChangeNotification a las notificaciones.
// Listen to all notifications posted for any object
var token = NSUserDefaults.Notifications.ObserveDidChange ((notification) => {
Console.WriteLine ("Observed DidChangeNotification!");
};
// Listen to all notifications posted for a single object
var token = NSUserDefaults.Notifications.ObserveDidChange (objectToObserve, (notification) => {
Console.WriteLine ($"Observed DidChangeNotification for {nameof (objectToObserve)}!");
};
// Stop listening for notifications
token.Dispose ();