GKPlayer.Notifications.ObserveDidChangeNotificationName Methode
Definition
Wichtig
Einige Informationen beziehen sich auf Vorabversionen, die vor dem Release ggf. grundlegend überarbeitet werden. Microsoft übernimmt hinsichtlich der hier bereitgestellten Informationen keine Gewährleistungen, seien sie ausdrücklich oder konkludent.
Überlädt
ObserveDidChangeNotificationName(EventHandler<NSNotificationEventArgs>) |
Stark typisierte Benachrichtigung für die DidChangeNotificationNameNotification Konstante. |
ObserveDidChangeNotificationName(NSObject, EventHandler<NSNotificationEventArgs>) |
Stark typisierte Benachrichtigung für die DidChangeNotificationNameNotification Konstante. |
ObserveDidChangeNotificationName(EventHandler<NSNotificationEventArgs>)
Stark typisierte Benachrichtigung für die DidChangeNotificationNameNotification Konstante.
public static Foundation.NSObject ObserveDidChangeNotificationName (EventHandler<Foundation.NSNotificationEventArgs> handler);
static member ObserveDidChangeNotificationName : EventHandler<Foundation.NSNotificationEventArgs> -> Foundation.NSObject
Parameter
- handler
- EventHandler<NSNotificationEventArgs>
Methode, die aufgerufen wird, wenn die Benachrichtigung bereitgestellt wird.
Gibt zurück
Tokenobjekt, das verwendet werden kann, um den Empfang von Benachrichtigungen zu beenden, indem es entweder entfernt oder an übergeben wird RemoveObservers(IEnumerable<NSObject>)
Hinweise
Das folgende Beispiel zeigt, wie Sie diese Methode in Ihrem Code verwenden können.
//
// Lambda style
//
// listening
notification = GKPlayer.Notifications.ObserveDidChangeNotificationName ((sender, args) => {
/* Access strongly typed args */
Console.WriteLine ("Notification: {0}", args.Notification);
});
// To stop listening:
notification.Dispose ();
//
//Method style
//
NSObject notification;
void Callback (object sender, Foundation.NSNotificationEventArgs args)
{
// Access strongly typed args
Console.WriteLine ("Notification: {0}", args.Notification);
}
void Setup ()
{
notification = GKPlayer.Notifications.ObserveDidChangeNotificationName (Callback);
}
void Teardown ()
{
notification.Dispose ();
}
Gilt für:
ObserveDidChangeNotificationName(NSObject, EventHandler<NSNotificationEventArgs>)
Stark typisierte Benachrichtigung für die DidChangeNotificationNameNotification Konstante.
public static Foundation.NSObject ObserveDidChangeNotificationName (Foundation.NSObject objectToObserve, EventHandler<Foundation.NSNotificationEventArgs> handler);
static member ObserveDidChangeNotificationName : Foundation.NSObject * EventHandler<Foundation.NSNotificationEventArgs> -> Foundation.NSObject
Parameter
- objectToObserve
- NSObject
Das zu beobachtende Objekt.
- handler
- EventHandler<NSNotificationEventArgs>
Methode, die aufgerufen wird, wenn die Benachrichtigung bereitgestellt wird.
Gibt zurück
Tokenobjekt, das verwendet werden kann, um den Empfang von Benachrichtigungen zu beenden, indem es entweder entfernt oder an übergeben wird RemoveObservers(IEnumerable<NSObject>)
Hinweise
Diese Methode kann verwendet werden, um Benachrichtigungen zu abonnieren DidChangeNotificationNameNotification .
// Listen to all notifications posted for any object
var token = GKPlayer.Notifications.ObserveDidChangeNotificationName ((notification) => {
Console.WriteLine ("Observed DidChangeNotificationNameNotification!");
};
// Listen to all notifications posted for a single object
var token = GKPlayer.Notifications.ObserveDidChangeNotificationName (objectToObserve, (notification) => {
Console.WriteLine ($"Observed DidChangeNotificationNameNotification for {nameof (objectToObserve)}!");
};
// Stop listening for notifications
token.Dispose ();