GKPlayer.Notifications.ObserveDidChangeNotificationName Metode
Definisi
Penting
Beberapa informasi terkait produk prarilis yang dapat diubah secara signifikan sebelum dirilis. Microsoft tidak memberikan jaminan, tersirat maupun tersurat, sehubungan dengan informasi yang diberikan di sini.
Overload
ObserveDidChangeNotificationName(EventHandler<NSNotificationEventArgs>) |
Pemberitahuan yang sangat ditik untuk DidChangeNotificationNameNotification konstanta. |
ObserveDidChangeNotificationName(NSObject, EventHandler<NSNotificationEventArgs>) |
Pemberitahuan yang sangat ditik untuk DidChangeNotificationNameNotification konstanta. |
ObserveDidChangeNotificationName(EventHandler<NSNotificationEventArgs>)
Pemberitahuan yang sangat ditik untuk DidChangeNotificationNameNotification konstanta.
public static Foundation.NSObject ObserveDidChangeNotificationName (EventHandler<Foundation.NSNotificationEventArgs> handler);
static member ObserveDidChangeNotificationName : EventHandler<Foundation.NSNotificationEventArgs> -> Foundation.NSObject
Parameter
- handler
- EventHandler<NSNotificationEventArgs>
Metode untuk memanggil saat pemberitahuan diposting.
Mengembalikan
Objek token yang dapat digunakan untuk berhenti menerima pemberitahuan dengan membuangnya atau meneruskannya ke RemoveObservers(IEnumerable<NSObject>)
Keterangan
Contoh berikut menunjukkan bagaimana Anda dapat menggunakan metode ini dalam kode Anda
//
// 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 ();
}
Berlaku untuk
ObserveDidChangeNotificationName(NSObject, EventHandler<NSNotificationEventArgs>)
Pemberitahuan yang sangat ditik untuk DidChangeNotificationNameNotification konstanta.
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
Objek yang akan diamati.
- handler
- EventHandler<NSNotificationEventArgs>
Metode untuk memanggil saat pemberitahuan diposting.
Mengembalikan
Objek token yang dapat digunakan untuk berhenti menerima pemberitahuan dengan membuangnya atau meneruskannya ke RemoveObservers(IEnumerable<NSObject>)
Keterangan
Metode ini dapat digunakan untuk berlangganan DidChangeNotificationNameNotification pemberitahuan.
// 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 ();